¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <a-spin :spinning="confirmLoading"> |
| | | <vxe-toolbar> |
| | | <template v-slot:buttons> |
| | | <vxe-button status="primary" @click="insertEvent()">æ°å¢</vxe-button> |
| | | <vxe-button status="danger" @click="handleBatchRemove()">æ¹éå é¤</vxe-button> |
| | | </template> |
| | | </vxe-toolbar> |
| | | <vxe-table |
| | | ref="editableDetailTable" |
| | | border |
| | | resizable |
| | | show-overflow |
| | | keep-source |
| | | :height="300" |
| | | :loading="confirmLoading" |
| | | :data="dataSource" |
| | | :edit-rules="validRules" |
| | | :edit-config="{trigger: 'manual', mode: 'row', showStatus: true}" |
| | | style="margin-top: 8px;"> |
| | | <vxe-table-column type="checkbox" width="60"></vxe-table-column> |
| | | <vxe-table-column type="seq" width="60"></vxe-table-column> |
| | | <vxe-table-column title="ID" field="id" :visible="false"></vxe-table-column> |
| | | <vxe-table-column title="equipmentId" field="equipmentId" :visible="false"></vxe-table-column> |
| | | <vxe-table-column title="åæ°åç§°" field="parameterId" align="center" |
| | | :edit-render="{name : '$select', options: processParameterList, optionProps: {label:'parameterName', value:'id'}, props: {clearable:true}, events: {change:handleParamSelectChange}}"></vxe-table-column> |
| | | <vxe-table-column title="åæ°ç¼ç " field="parameterCode" align="center"></vxe-table-column> |
| | | <vxe-table-column title="计éåä½" field="parameterUnit" align="center"></vxe-table-column> |
| | | <vxe-table-column title="åæ°èå´" field="parameterPeriod" align="center" |
| | | :edit-render="{name : '$input'}"></vxe-table-column> |
| | | <vxe-table-column title="æä½" width="160"> |
| | | <template v-slot="{row}"> |
| | | <template v-if="hasEditStatus(row)"> |
| | | <vxe-button @click="saveRowEvent(row)">ä¿å</vxe-button> |
| | | <vxe-button @click="cancelRowEvent(row)">åæ¶</vxe-button> |
| | | </template> |
| | | <template v-else> |
| | | <vxe-button @click="editRowEvent(row)">ç¼è¾</vxe-button> |
| | | <vxe-button @click="handleRemove(row)">å é¤</vxe-button> |
| | | </template> |
| | | |
| | | </template> |
| | | </vxe-table-column> |
| | | </vxe-table> |
| | | </a-spin> |
| | | </template> |
| | | |
| | | <script> |
| | | import { deleteAction, getAction, httpAction } from '@/api/manage' |
| | | |
| | | export default { |
| | | name: 'EamEquipmentProcessModal', |
| | | data() { |
| | | return { |
| | | title: 'æä½', |
| | | confirmLoading: false, |
| | | url: { |
| | | add: '/eam/equipmentProcessParameters/add', |
| | | edit: '/eam/equipmentProcessParameters/edit', |
| | | list: '/eam/equipmentProcessParameters/list', |
| | | delete: '/eam/equipmentProcessParameters/delete', |
| | | deleteBatch: '/eam/equipmentProcessParameters/deleteBatch', |
| | | processParamList: '/eam/processParameters/listAll' |
| | | }, |
| | | /* å页忰 */ |
| | | ipagination: { |
| | | current: 1, |
| | | pageSize: 10, |
| | | pageSizeOptions: ['10', '20', '30'], |
| | | showTotal: (total, range) => { |
| | | return range[0] + '-' + range[1] + ' å
±' + total + 'æ¡' |
| | | }, |
| | | showQuickJumper: true, |
| | | showSizeChanger: true, |
| | | total: 0 |
| | | }, |
| | | dataSource: [], |
| | | processParameterList: [], |
| | | queryParam: { |
| | | equipmentId: '-1' |
| | | }, |
| | | validRules: { |
| | | parameterId: [ |
| | | { required: true, message: 'è¯·éæ©åæ°ï¼' } |
| | | ], |
| | | parameterPeriod: [ |
| | | { required: true, message: '请è¾å
¥åæ°èå´ï¼' } |
| | | ] |
| | | } |
| | | } |
| | | }, |
| | | created() { |
| | | this.loadProcessParameterList() |
| | | }, |
| | | methods: { |
| | | handleParamSelectChange($event, value) { |
| | | let parameter = this.processParameterList.find(item => item.id === value.value) |
| | | if (parameter) { |
| | | $event.row.parameterUnit = parameter.parameterUnit |
| | | $event.row.parameterCode = parameter.parameterCode |
| | | } else { |
| | | $event.row.parameterUnit = undefined |
| | | $event.row.parameterCode = undefined |
| | | } |
| | | }, |
| | | loadProcessParameterList() { |
| | | getAction(this.url.processParamList).then(res => { |
| | | if (res.success) { |
| | | this.processParameterList = [...res.result] |
| | | } |
| | | }) |
| | | }, |
| | | onClearSelected() { |
| | | this.dataSource = [] |
| | | this.queryParam.equipmentId = '-1' |
| | | this.ipagination.current = 1 |
| | | this.ipagination.total = 0 |
| | | }, |
| | | loadData(args) { |
| | | if (!this.url.list) { |
| | | this.$message.error('请设置url.list屿§!') |
| | | return |
| | | } |
| | | if (args === 1) { |
| | | this.ipagination.current = 1 |
| | | } |
| | | // å°è£
æ¥è¯¢æ¡ä»¶ |
| | | let formData = { |
| | | pageNo: args, |
| | | pageSize: this.ipagination.pageSize, |
| | | equipmentId: this.queryParam.equipmentId |
| | | } |
| | | // è°ç¨æ¥è¯¢æ°æ®æ¥å£ |
| | | this.confirmLoading = true |
| | | getAction(this.url.list, formData).then(res => { |
| | | if (res.success) { |
| | | // åå°æ¥è¯¢åæ¥ç totalï¼æ°æ®æ»æ°é |
| | | this.dataSource = res.result.records || res.result |
| | | if (res.result.total) { |
| | | this.ipagination.total = res.result.total |
| | | } else { |
| | | this.ipagination.total = 0 |
| | | } |
| | | } else { |
| | | this.$message.warning(res.message) |
| | | } |
| | | }).finally(() => { |
| | | // è¿éæ¯æ 论æåæå¤±è´¥é½ä¼æ§è¡çæ¹æ³ï¼å¨è¿éå
³éloading |
| | | this.confirmLoading = false |
| | | }) |
| | | }, |
| | | async insertEvent() { |
| | | let record = { equipmentId: this.queryParam.equipmentId } |
| | | let { row: newRow } = await this.$refs.editableDetailTable.insert(record) |
| | | await this.$refs.editableDetailTable.setActiveCell(newRow, 'parameterId') |
| | | }, |
| | | async saveRowEvent(row) { |
| | | let that = this |
| | | const errMap = await that.$refs.editableDetailTable.validate().catch(errMap => errMap) |
| | | if (errMap) { |
| | | that.$message.warning('æ ¡éªä¸éè¿,请补å
å¿
填项ï¼') |
| | | return |
| | | } |
| | | that.confirmLoading = true |
| | | let httpurl = '' |
| | | let method = '' |
| | | if (!row.id) { |
| | | httpurl += that.url.add |
| | | method = 'post' |
| | | } else { |
| | | httpurl += that.url.edit |
| | | method = 'put' |
| | | } |
| | | let res = await httpAction(httpurl, row, method) |
| | | if (res.success) { |
| | | that.$message.success(res.message) |
| | | that.loadData(that.ipagination.current) |
| | | await that.$refs.editableDetailTable.clearActived() |
| | | } else { |
| | | that.$message.warning(res.message) |
| | | } |
| | | that.confirmLoading = false |
| | | }, |
| | | handleRemove(row) { |
| | | let xTable = this.$refs.editableDetailTable |
| | | let that = this |
| | | this.$confirm({ |
| | | content: `确认è¦å é¤åï¼`, |
| | | onOk: () => { |
| | | if (row.id) { |
| | | //å端å é¤ |
| | | deleteAction(that.url.delete, { id: row.id }).then((res) => { |
| | | if (res.success) { |
| | | that.reCalculatePage(1) |
| | | that.$message.success(res.message) |
| | | that.loadData(that.ipagination.current) |
| | | } else { |
| | | that.$message.warning(res.message) |
| | | } |
| | | }) |
| | | } else { |
| | | //å端å é¤ |
| | | xTable.remove(row) |
| | | } |
| | | }, |
| | | onCancel: () => { |
| | | xTable.setActiveCell(row, 'parameterId') |
| | | } |
| | | }) |
| | | }, |
| | | handleBatchRemove(){ |
| | | let xTable = this.$refs.editableDetailTable |
| | | let that = this |
| | | let checkboxRecords = xTable.getCheckboxRecords(); |
| | | if(checkboxRecords && checkboxRecords.length > 0) { |
| | | let ids = checkboxRecords.map(record => record.id); |
| | | this.$confirm({ |
| | | title: "确认å é¤", |
| | | content: "æ¯å¦å é¤é䏿°æ®?", |
| | | onOk: function () { |
| | | that.confirmLoading = true; |
| | | deleteAction(that.url.deleteBatch, {ids: ids.join(',')}).then((res) => { |
| | | if (res.success) { |
| | | //éæ°è®¡ç®å页é®é¢ |
| | | that.reCalculatePage(checkboxRecords.length) |
| | | that.$message.success(res.message); |
| | | that.loadData(that.ipagination.current); |
| | | } else { |
| | | that.$message.warning(res.message); |
| | | } |
| | | }).finally(() => { |
| | | that.confirmLoading = false; |
| | | }); |
| | | } |
| | | }); |
| | | } else { |
| | | that.$message.warning('请å
é䏿°æ®è¡ï¼'); |
| | | } |
| | | }, |
| | | editRowEvent(row) { |
| | | this.$refs.editableDetailTable.setActiveRow(row) |
| | | }, |
| | | cancelRowEvent(row) { |
| | | let xTable = this.$refs.editableDetailTable |
| | | this.$confirm({ |
| | | content: `ç¡®è®¤è¦æ¾å¼ç¼è¾åï¼`, |
| | | onOk: () => { |
| | | xTable.revertData() |
| | | }, |
| | | onCancel: () => { |
| | | xTable.setActiveCell(row, 'parameterId') |
| | | } |
| | | }) |
| | | }, |
| | | hasEditStatus(row) { |
| | | const $table = this.$refs.editableDetailTable |
| | | if ($table) { |
| | | return $table.isActiveByRow(row) |
| | | } |
| | | return false |
| | | }, |
| | | reCalculatePage(count) { |
| | | //æ»æ°é-count |
| | | let total = this.ipagination.total - count |
| | | //è·åå é¤åçåé¡µæ° |
| | | let currentIndex = Math.ceil(total / this.ipagination.pageSize) |
| | | //å é¤åçå页æ°<æå¨å½å页 |
| | | if (currentIndex < this.ipagination.current) { |
| | | this.ipagination.current = currentIndex |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="less" scoped> |
| | | |
| | | </style> |