| | |
| | | @size-change="sizeChange" @row-dblclick="handleRowClick" @row-update="handleUpdate" |
| | | @selection-change="selectChange"> |
| | | <template slot="menuLeft"> |
| | | <!-- <el-button plain size="small" type="success" @click="savaHandler">保存</el-button>--> |
| | | <el-button plain size="small" type="primary" @click="syncHandler">同步</el-button> |
| | | <el-button v-if="permissionList.saveBtn" plain size="small" type="success" @click="savaHandler">保存</el-button> |
| | | <el-button v-if="permissionList.syncBtn" plain size="small" type="primary" @click="syncHandler">同步</el-button> |
| | | <span style="width: 200px;display: inline-block"> |
| | | <el-select slot="prepend" v-model="searchSelect" placeholder="请选择" size="small"> |
| | | <el-option v-for="item in searchData" :key="item.prop" :label="item.label" :value="item.prop" |
| | | ></el-option> |
| | | </el-select> |
| | | </span> |
| | | <span style="margin-left: 5px"> |
| | | <el-input v-model="searchValue" class="attrSearch" clearable placeholder="请输入内容" |
| | | prefix-icon="el-icon-search" |
| | | size="small" type="text"></el-input> |
| | | <el-button v-if="permissionList.searchBtn" icon="el-icon-search" plain size="small" type="primary" |
| | | @click="searchHandler"> 搜索</el-button> |
| | | </span> |
| | | </template> |
| | | </avue-crud> |
| | | </basic-container> |
| | |
| | | <script> |
| | | import {getGroupAttrPoolALlList, editGroupAttr, syncGroupAttrMapping} from '@/api/vciAttrbute' |
| | | import {getPage} from "@/api/omd/OmdAttribute"; |
| | | import {mapGetters} from "vuex"; |
| | | |
| | | export default { |
| | | name: "vciAttribute", |
| | | data() { |
| | | return { |
| | | searchSelect: "groupAttrKey", |
| | | searchValue: '', |
| | | searchData: [ |
| | | { |
| | | label: "集团属性编号", |
| | | prop: "groupAttrKey", |
| | | align: "left", |
| | | display: false, |
| | | width: 200, |
| | | required: true |
| | | }, { |
| | | label: "集团属性名称", |
| | | prop: "groupAttrName", |
| | | align: "left", |
| | | display: false |
| | | } |
| | | ], |
| | | data: [], |
| | | options: { |
| | | height: 'auto', |
| | | calcHeight: 20, |
| | | headerAlign: "center", |
| | | border: true, |
| | | // selection: true, |
| | | selection: true, |
| | | tip: false, |
| | | index: true, |
| | | refreshBtn: false, |
| | |
| | | } |
| | | }, |
| | | created() { |
| | | const params = { |
| | | 'conditionMap[groupAttrKey_like]': 'RY_', |
| | | page: this.page.currentPage, |
| | | limit: this.page.pageSize |
| | | } |
| | | this.onLoad(params) |
| | | this.onLoad() |
| | | this.codeColumnOnload() |
| | | }, |
| | | computed: { |
| | | codeMetaColumn() { |
| | | return this.options.column.find(column => column.prop === 'codeMetaAttrName'); |
| | | } |
| | | }, |
| | | ...mapGetters(["permission"]), |
| | | permissionList() { |
| | | return { |
| | | saveBtn: this.vaildData(this.permission.vciAttribute.attribute_save, false), |
| | | syncBtn: this.vaildData(this.permission.vciAttribute.attribute_sync, false), |
| | | searchBtn: this.vaildData(this.permission.vciAttribute.attribute_search, false), |
| | | } |
| | | }, |
| | | }, |
| | | methods: { |
| | | searchHandler() { |
| | | console.log(this.searchSelect) |
| | | const params = { |
| | | [`conditionMap[${this.searchSelect}_like]`]: this.searchValue, |
| | | page: this.page.currentPage, |
| | | limit: this.page.pageSize |
| | | } |
| | | getGroupAttrPoolALlList(params).then(res => { |
| | | const data = res.data.data; |
| | | this.data = data.records; |
| | | this.page.total = data.total; |
| | | }) |
| | | }, |
| | | codeMetaDis() { |
| | | for (const item of this.data) { |
| | | if (item.codeMetaAttrOid && item.codeMetaAttrKey && item.codeMetaAttrName) { |
| | |
| | | selectChange(list) { |
| | | this.selectList = list; |
| | | }, |
| | | async onLoad(params) { |
| | | async onLoad() { |
| | | const params = { |
| | | page: this.page.currentPage, |
| | | limit: this.page.pageSize |
| | | } |
| | | getGroupAttrPoolALlList(params).then(res => { |
| | | const data = res.data.data; |
| | | this.data = data.records; |
| | |
| | | |
| | | // row.codeMetaAttrName因为下拉框value值原因绑定为codeMetaAttrOid |
| | | let updataList = [] |
| | | // console.log(this.ChangeName) |
| | | // console.log(row.codeMetaAttrName) |
| | | // if (this.ChangeName && this.ChangeName === row.codeMetaAttrName) { |
| | | // updataList = this.codeMetaColumn.dicData.find(item => item.codeMetaAttrOid === row.codeMetaAttrOid) |
| | | // } else { |
| | | // console.log('2') |
| | | // updataList = this.codeMetaColumn.dicData.find(item => item.codeMetaAttrOid === row.codeMetaAttrName) |
| | | // } |
| | | updataList = this.codeMetaColumn.dicData.find(item => item.codeMetaAttrOid === row.codeMetaAttrName) |
| | | |
| | | if (this.ChangeName && this.ChangeName === row.codeMetaAttrName) { |
| | | updataList = this.codeMetaColumn.dicData.find(item => item.codeMetaAttrOid === row.codeMetaAttrOid) |
| | | } else { |
| | | if (row.codeMetaAttrName !== "" && row.codeMetaAttrName) { |
| | | updataList = this.codeMetaColumn.dicData.find(item => item.codeMetaAttrOid === row.codeMetaAttrName) |
| | | } |
| | | } |
| | | // 因为row里面的值是不正确的 重新赋值一遍 |
| | | if (updataList) { |
| | | const {codeMetaAttrOid, codeMetaAttrKey, codeMetaAttrName} = updataList; |
| | | Object.assign(row, {codeMetaAttrOid, codeMetaAttrKey, codeMetaAttrName}); |
| | | Object.assign(row, { |
| | | codeMetaAttrOid: codeMetaAttrOid, |
| | | codeMetaAttrKey: codeMetaAttrKey.toLowerCase(), |
| | | codeMetaAttrName: codeMetaAttrName |
| | | }); |
| | | } |
| | | |
| | | const objet = { |
| | |
| | | codeMetaAttrKey: row.codeMetaAttrKey, |
| | | codeMetaAttrName: row.codeMetaAttrName |
| | | } |
| | | |
| | | const response = await editGroupAttr([objet]) |
| | | if (response.data.success) { |
| | | this.$message.success('保存成功!') |
| | |
| | | } else { |
| | | const hasTrueValue = this.selectList.some(item => !item.$cellEdit); |
| | | if (hasTrueValue) { |
| | | this.$message.warning('请开启编辑后保存!') |
| | | } else { |
| | | let saveList = [] |
| | | for (const item of this.selectList) { |
| | | console.log(item) |
| | | const updataList = this.codeMetaColumn.dicData.find(p => p.codeMetaAttrOid === item.codeMetaAttrName); |
| | | const {codeMetaAttrOid, codeMetaAttrKey, codeMetaAttrName} = updataList; |
| | | Object.assign(item, {codeMetaAttrOid, codeMetaAttrKey, codeMetaAttrName}); |
| | | console.log(updataList) |
| | | item.$cellEdit = false; |
| | | saveList.push({ |
| | | oid: item.oid, |
| | | groupAttrKey: item.groupAttrKey, |
| | | groupAttrName: item.groupAttrName, |
| | | codeMetaAttrOid: item.codeMetaAttrOid, |
| | | codeMetaAttrKey: item.codeMetaAttrKey, |
| | | codeMetaAttrName: item.codeMetaAttrName |
| | | }) |
| | | } |
| | | const response = await editGroupAttr(saveList) |
| | | if (response.data.success) { |
| | | this.$message.success('保存成功!') |
| | | } |
| | | this.$message.warning('请开启编辑后进行保存!') |
| | | return |
| | | } |
| | | const codeMetaInput = this.selectList.some(item => item.codeMetaAttrName === ""); |
| | | if (codeMetaInput) { |
| | | this.$message.warning('请检查已勾选数据中是否存在未选择的项!'); |
| | | return |
| | | } |
| | | let saveList = [] |
| | | for (const item of this.selectList) { |
| | | const updataList = this.codeMetaColumn.dicData.find(column => column.codeMetaAttrOid === item.codeMetaAttrName); |
| | | if (updataList) { |
| | | const {codeMetaAttrOid, codeMetaAttrKey, codeMetaAttrName} = updataList; |
| | | Object.assign(item, { |
| | | codeMetaAttrOid: codeMetaAttrOid, |
| | | codeMetaAttrKey: codeMetaAttrKey.toLowerCase(), |
| | | codeMetaAttrName: codeMetaAttrName |
| | | }); |
| | | } |
| | | item.$cellEdit = false; |
| | | saveList.push({ |
| | | oid: item.oid, |
| | | groupAttrKey: item.groupAttrKey, |
| | | groupAttrName: item.groupAttrName, |
| | | codeMetaAttrOid: item.codeMetaAttrOid, |
| | | codeMetaAttrKey: item.codeMetaAttrKey, |
| | | codeMetaAttrName: item.codeMetaAttrName |
| | | }) |
| | | } |
| | | const response = await editGroupAttr(saveList) |
| | | if (response.data.success) { |
| | | this.$message.success('保存成功!') |
| | | await this.onLoad() |
| | | } |
| | | |
| | | } |
| | | }, |
| | | async syncHandler() { |
| | |
| | | const response = await syncGroupAttrMapping(syncList) |
| | | if (response.data.success) { |
| | | this.$message.success(response.data.msg); |
| | | const params = { |
| | | 'conditionMap[groupAttrKey_like]': 'RY_', |
| | | page: this.page.currentPage, |
| | | limit: this.page.pageSize |
| | | } |
| | | await this.onLoad(params) |
| | | |
| | | await this.onLoad() |
| | | } |
| | | } |
| | | }, |
| | | currentChange(currentPage) { |
| | | this.page.currentPage = currentPage; |
| | | const params = { |
| | | 'conditionMap[groupAttrKey_like]': 'RY_', |
| | | page: this.page.currentPage, |
| | | limit: this.page.pageSize |
| | | } |
| | | this.onLoad(params) |
| | | |
| | | this.onLoad() |
| | | }, |
| | | sizeChange(pageSize) { |
| | | this.page.pageSize = pageSize; |
| | | const params = { |
| | | 'conditionMap[groupAttrKey_like]': 'RY_', |
| | | page: this.page.currentPage, |
| | | limit: this.page.pageSize |
| | | } |
| | | this.onLoad(params) |
| | | |
| | | this.onLoad() |
| | | }, |
| | | } |
| | | } |