| | |
| | | sortable="custom" |
| | | > |
| | | <template slot-scope="{row}"> |
| | | {{ row.idunitgroup ? '' : row.code }} |
| | | {{ row.isGroup === '0' ? row.code :(!isMainUnitHidden?row.code:'') }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | |
| | | label="计量单位名称" |
| | | sortable="custom" |
| | | /> |
| | | <!-- <el-table-column--> |
| | | <!-- prop="isGroup"--> |
| | | <!-- label="是否多计量"--> |
| | | <!-- sortable="custom"--> |
| | | <!-- >--> |
| | | <!-- <template slot-scope="{row}">--> |
| | | <!-- <el-tag v-if="row.isGroup==='1'" size="small" type="success">是</el-tag>--> |
| | | <!-- <el-tag v-if="row.isGroup==='0'" size="small" type="info">否</el-tag>--> |
| | | <!-- </template>--> |
| | | <!-- </el-table-column>--> |
| | | <el-table-column |
| | | v-if="!isMainUnitHidden" |
| | | prop="isMainUnit" |
| | | label="主计量" |
| | | sortable="custom" |
| | | > |
| | | <template slot-scope="{row}"> |
| | | {{ row.isMainUnit === '1' ? '是' : '否' }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | v-if="!isMainUnitHidden" |
| | | prop="changeRate" |
| | | label="换算率" |
| | | sortable="custom" |
| | | /> |
| | | |
| | | <el-table-column |
| | | prop="data_sources" |
| | | label="数据来源" |
| | | sortable="custom" |
| | | /> |
| | | <el-table-column |
| | | prop="lm_user" |
| | | label="创建人员" |
| | |
| | | <el-table-column |
| | | prop="lm_date" |
| | | label="创建时间" |
| | | |
| | | sortable="custom" |
| | | /> |
| | | <el-table-column |
| | |
| | | @click="edit('edit',row)" |
| | | /> |
| | | </el-tooltip> |
| | | |
| | | <el-tooltip v-del-tab-index class="item" effect="dark" content="删除" placement="top"> |
| | | <i |
| | | class="el-icon-delete" |
| | |
| | | import elDragDialog from '@/directive/el-drag-dialog' |
| | | import waves from '@/directive/waves' |
| | | import { SaveSearchUnit } from '@/api/ErpSyncMes' |
| | | import { AddUpdateTUnit, TUnitData, TUnitGroup, TUnitGroupProject } from '@/api/ProductModel' |
| | | import { AddUpdateTUnit, DeleteTUnit, TUnitData, TUnitGroup, TUnitGroupProject } from '@/api/ProductModel' |
| | | |
| | | export default { |
| | | name: 'Zzjg', |
| | |
| | | checkboxSelectedArr: [ |
| | | { code: '0', name: '否' }, |
| | | { code: '1', name: '是' } |
| | | ] |
| | | ], |
| | | |
| | | isMainUnitHidden: true |
| | | |
| | | } |
| | | }, |
| | |
| | | mounted() { |
| | | window.addEventListener('resize', this.getHeight) |
| | | this.getHeight() |
| | | |
| | | this.getTUnitGroup('') |
| | | this.getTUnitData() |
| | | this.handleGetApi('') |
| | | }, |
| | | methods: { |
| | | async handleGetApi(code) { |
| | | await this.getTUnitGroup(code) |
| | | await this.getTUnitData() |
| | | }, |
| | | async getSaveSearchUnit() { |
| | | const res = await SaveSearchUnit() |
| | | if (res.code === '200') { |
| | | await this.getTUnitGroup('') |
| | | await this.getTUnitData() |
| | | await this.handleGetApi(this.$refs.treeLeftRef.getCurrentKey()) |
| | | this.$notify.success('计量单位同步成功!') |
| | | } |
| | | }, |
| | |
| | | unitcode, isgroup: '1' |
| | | } |
| | | const res = await TUnitGroupProject(data) |
| | | this.tableData = res.data |
| | | res.data.forEach((i, index) => { |
| | | i.unitname = i.name |
| | | i.unitcode = i.code |
| | | i.uuid = new Date().getTime() + index |
| | | i.isVisible = 0 |
| | | // i.idunitgroup = unitcode |
| | | i.checkboxSelected = i.isMainUnit === '1' ? '1' : '0' |
| | | }) |
| | | this.tableDataDialog = res.data |
| | | }, |
| | | |
| | | // 排序改变时 |
| | |
| | | } |
| | | this.form.order = order |
| | | this.form.prop = prop |
| | | this.getTUnitGroup() |
| | | this.getTUnitData() |
| | | }, |
| | | nodeClick(obj, Node, VueComponent) { |
| | | async nodeClick(obj, Node, VueComponent) { |
| | | if (obj.code === 'S' || obj.code === 'M' || obj.code === '') { |
| | | this.form.tunittype = obj.code |
| | | this.form.tunitgroupcode = '' |
| | | this.getTUnitData(obj.code) |
| | | await this.getTUnitData(obj.code) |
| | | this.isMainUnitHidden = true |
| | | this.$nextTick(() => { |
| | | this.$refs.tableDataRef.doLayout() |
| | | }) |
| | | } else { |
| | | this.form.tunittype = 'M' |
| | | this.form.tunitgroupcode = obj.code |
| | | this.getTUnitData(obj.code) |
| | | await this.getTUnitData(obj.code) |
| | | this.isMainUnitHidden = false |
| | | this.$nextTick(() => { |
| | | this.$refs.tableDataRef.doLayout() |
| | | }) |
| | | } |
| | | }, |
| | | add(operation) { |
| | |
| | | this.dialogForm.OperType = 'Update' |
| | | |
| | | this.$nextTick(() => { |
| | | if (this.$refs.treeLeftRef.getCurrentKey() === 'S' || this.$refs.treeLeftRef.getCurrentKey() === 'M' || this.$refs.treeLeftRef.getCurrentKey() === '') { |
| | | this.dialogForm.tunittype = row.isGroup === '0' ? 'S' : 'M' |
| | | this.dialogForm.tunitgroupcode = row.isGroup === '0' ? '' : row.code |
| | | this.dialogForm.tunitgroupcode = row.isGroup === '0' ? row.code : row.idunitgroup |
| | | this.dialogForm.unitcode = row.code |
| | | this.dialogForm.unitname = row.name |
| | | this.dialogForm.data_sources = row.data_sources |
| | | } else { |
| | | this.dialogForm.tunittype = 'M' |
| | | this.dialogForm.tunitgroupcode = row.idunitgroup |
| | | this.dialogForm.unitcode = row.idunitgroup |
| | | this.dialogForm.unitname = this.treeLeft[0].children[1].children.find(i => i.code === this.$refs.treeLeftRef.getCurrentKey()).name |
| | | this.dialogForm.data_sources = row.data_sources |
| | | } |
| | | |
| | | if (this.dialogForm.tunittype === 'M') { |
| | | this.getTUnitGroupProject(row.idunitgroup) |
| | | } |
| | | }) |
| | | }, |
| | | |
| | |
| | | cancelButtonText: '取消', |
| | | type: 'warning' |
| | | }).then(() => { |
| | | // DeleteUserSave({ usercode: row.usercode }).then(res => { |
| | | // if (res.code === '200') { |
| | | // this.$notify.success('删除成功!') |
| | | // if (this.form.page > 1 && this.tableData.length === 1) { |
| | | // this.form.page-- |
| | | // } |
| | | // this.getTUnitGroup() |
| | | // } |
| | | // }) |
| | | if (this.$refs.treeLeftRef.getCurrentKey() === 'S' || this.$refs.treeLeftRef.getCurrentKey() === 'M' || this.$refs.treeLeftRef.getCurrentKey() === '') { |
| | | // this.dialogForm.tunittype = this.$refs.treeLeftRef.getCurrentKey() |
| | | } else { |
| | | if (row.isMainUnit === '1' || this.tableData.length === 2) { |
| | | return this.$message.info('计量单位组下,必须有一个主计量和至少一个辅计量!') |
| | | } |
| | | } |
| | | |
| | | const data = { |
| | | data_sources: row.data_sources, |
| | | tunittype: row.isGroup === '0' ? 'S' : 'M', |
| | | |
| | | tunitgroupcode: row.isGroup === '0' ? '' : row.idunitgroup, |
| | | tunitcode: row.isGroup === '0' ? row.code : (this.$refs.treeLeftRef.getCurrentKey() === 'M' ? '' : row.code) |
| | | } |
| | | DeleteTUnit(data).then(res => { |
| | | if (res.code === '200') { |
| | | this.$notify.success('删除成功!') |
| | | if (this.form.page > 1 && this.tableData.length === 1) { |
| | | this.form.page-- |
| | | } |
| | | |
| | | this.handleGetApi(this.$refs.treeLeftRef.getCurrentKey()) |
| | | } |
| | | }) |
| | | }).catch(() => { |
| | | this.$notify.info('已取消删除') |
| | | }) |
| | |
| | | dialogVisibleConfirm() { |
| | | this.$refs.dialogForm.validate(valid => { |
| | | if (valid) { |
| | | if (this.tableDataDialog.find(i => i.isVisible === 1)) { |
| | | return this.$message.info('请先保存当前行!') |
| | | } |
| | | |
| | | let data |
| | | if (this.dialogForm.tunittype === 'S') { // 单计量新增,修改 |
| | | data = [{ |
| | |
| | | } |
| | | |
| | | this.tableDataDialog.forEach((i, index) => { |
| | | i.unitcode = index + 1 |
| | | i.isMainUnit = '1' |
| | | i.unitcode = i.unitcode ? i.unitcode : 'U' + index.toString() |
| | | i.isMainUnit = i.checkboxSelected === '1' ? '1' : '0' |
| | | i.isSingleUnit = '0' |
| | | i.disabled = '0' |
| | | i.isGroup = '1' |
| | |
| | | children: this.tableDataDialog |
| | | }] |
| | | } |
| | | |
| | | // console.log(JSON.parse(JSON.stringify(data))) |
| | | |
| | | console.log(data) |
| | | this.$store.state.app.buttonIsDisabled = true |
| | | AddUpdateTUnit(data, this.dialogForm.data_sources, this.dialogForm.tunittype, this.dialogForm.tunitgroupcode, this.dialogForm.OperType).then(res => { |
| | | if (res.code === '200') { |
| | | this.$notify.success(this.operation === 'add' ? '添加成功!' : '修改成功!') |
| | | this.dialogVisible = false |
| | | this.$store.state.app.buttonIsDisabled = false |
| | | this.getTUnitData() |
| | | if (this.dialogForm.tunittype === 'M') { |
| | | this.getTUnitGroup('M') |
| | | } |
| | | this.handleGetApi(this.$refs.treeLeftRef.getCurrentKey()) |
| | | } else { |
| | | this.$store.state.app.buttonIsDisabled = false |
| | | this.$notify.error(this.operation === 'add' ? '添加失败!' : '修改失败!') |
| | |
| | | }, |
| | | |
| | | tableDataDialogAdd() { |
| | | // 'unitcode': this.dialogForm.unitcode, |
| | | // 'unitname': this.dialogForm.unitname, |
| | | // 'isMainUnit': '0', |
| | | // 'changeRate': '1', |
| | | // 'isSingleUnit': '1', |
| | | // 'disabled': '0', |
| | | // 'isGroup': '0', |
| | | // 'rateDescription': '', |
| | | // 'idunitgroup': '' |
| | | |
| | | if (this.tableDataDialog.find(i => i.isVisible === 1)) { |
| | | return this.$message.info('请先保存上一条数据!') |
| | | } |
| | |
| | | changeRate: 1, |
| | | uuid: new Date().getTime(), |
| | | checkboxSelected: this.tableDataDialog.length === 0 ? '1' : '0', |
| | | isVisible: 1 |
| | | isVisible: 1, |
| | | data_sources: 'MES' |
| | | }) |
| | | console.log(this.tableDataDialog) |
| | | }, |