¶Ô±ÈÐÂÎļþ |
| | |
| | | <!-- |
| | | * @Date: 2024-06-23 21:32:05 |
| | | * @LastEditors: Sneed |
| | | * @LastEditTime: 2024-06-23 23:45:09 |
| | | * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/console/basic-data/tpmComp2.vue |
| | | --> |
| | | <template> |
| | | <el-conatiner> |
| | | <el-header> |
| | | <el-button type="primary" @click="addNew">æ°å»º</el-button> |
| | | <import-table style="margin:0 8px" :exportUrl="exportUrlTpl" :uploadUrl="uploadUrl"></import-table> |
| | | <el-button type="primary" @click="exportData">导åº</el-button> |
| | | <el-popconfirm width="220" cancel-button-text="åç¨" confirm-button-text="å é¤" |
| | | title="å 餿°æ®ä¼å½±åå·²å
³èçä¸å¡ ,è¥æ¨æ³å¨å·²å
³èçä¸å¡ä¸ä¾ç¶æ¾ç¤ºè¿äºæ°æ®, æ¨å¯ä»¥éæ© åç¨ æä½ãåç¨åæ¤æ°æ®å°ä¸è½å被æ°ä¸å¡ä½¿ç¨ã" |
| | | @confirm="table_del(selection, '0')" @cancel="table_del(selection, '1')"> |
| | | <template #reference> |
| | | <el-button :disabled="selection.length == 0" type="danger" plain icon="el-icon-delete"></el-button> |
| | | </template> |
| | | </el-popconfirm> |
| | | <el-select v-model="params.status" placeholder="è¯·éæ©" style="width: 240px;margin-left: auto;"> |
| | | <template #prefix><span style="margin-right: 6px;">ç¶æ</span></template> |
| | | <el-option key="0" label="åç¨" :value="0" /> |
| | | <el-option key="1" label="å¯ç¨" :value="1" /> |
| | | </el-select> |
| | | <el-input style="width: 240px;margin-left: 8px;" v-model="params.keyWord" placeholder="请è¾å
¥æ£ç´¢å
容"></el-input> |
| | | <el-button @click="search" style="margin-left: 8px;" type="primary" icon="el-icon-search"></el-button> |
| | | <scDialog v-model="visible"> |
| | | <scForm v-if="visible" ref="form" :config="config" :rules="rules" v-model="form" @submit="submit"> |
| | | </scForm> |
| | | </scDialog> |
| | | </el-header> |
| | | <el-main> |
| | | <scTable ref="table" @selection-change="handleSelectionChange" row-key="id" border :apiObj="apiObj" stripe |
| | | @dataChange="dataChange"> |
| | | <el-table-column type="selection" width="55" /> |
| | | <el-table-column prop="code" label="æºå¨ç±»åç¼å·" /> |
| | | <el-table-column prop="name" label="æºå¨ç±»ååç§°" /> |
| | | <el-table-column prop="remark" label="夿³¨" /> |
| | | <el-table-column prop="statusName" label="ç¶æ" /> |
| | | <el-table-column label="æä½" fixed="right" align="left" width="170"> |
| | | <template #default="scope"> |
| | | <el-button-group> |
| | | <el-button text type="primary" size="small" |
| | | @click="viewCheck(scope.row, scope.$index)">ç¹æ£é¡¹ç®</el-button> |
| | | <el-button text type="primary" size="small" |
| | | @click="viewM(scope.row, scope.$index)">ä¿å
»é¡¹ç®</el-button> |
| | | <el-button text type="primary" size="small" |
| | | @click="table_edit(scope.row, scope.$index)">ç¼è¾</el-button> |
| | | <el-popconfirm width="220" cancel-button-text="åç¨" confirm-button-text="å é¤" |
| | | title="å 餿°æ®ä¼å½±åå·²å
³èçä¸å¡ ,è¥æ¨æ³å¨å·²å
³èçä¸å¡ä¸ä¾ç¶æ¾ç¤ºè¿äºæ°æ®, æ¨å¯ä»¥éæ© åç¨ æä½ãåç¨åæ¤æ°æ®å°ä¸è½å被æ°ä¸å¡ä½¿ç¨ã" |
| | | @confirm="table_del([scope.row], '0')" @cancel="table_del([scope.row], '1')"> |
| | | <template #reference> |
| | | <el-button type="danger" text size="small">å é¤</el-button> |
| | | </template> |
| | | </el-popconfirm> |
| | | </el-button-group> |
| | | </template> |
| | | </el-table-column> |
| | | </scTable> |
| | | </el-main> |
| | | <scDialog v-model="visibleCheck"> |
| | | <scFormTable ref="table1" v-model="tabledata" stripe hideDelete :addTemplate="addTemplate" |
| | | @row-click="getCheckListChild"> |
| | | <el-table-column label="ç¹æ£é¡¹ç®ç¼å·" prop="code"> |
| | | <template #default="scope"> |
| | | <el-select v-if="scope.row.isEdit" v-model="scope.row.checkProjectId" style="width: 100%;" |
| | | @change="changeCheck"> |
| | | <el-option v-for="(item, index) in options" :key="index" :label="item.code" |
| | | :value="item.id">{{ item.code }}</el-option> |
| | | </el-select> |
| | | <span v-else>{{ scope.row.code }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="ç¹æ£é¡¹ç®åç§°" prop="code"> |
| | | <template #default="scope"> |
| | | <el-select v-if="scope.row.isEdit" v-model="scope.row.checkProjectId" style="width: 100%;"> |
| | | <el-option v-for="(item, index) in options" :key="index" :label="item.name" |
| | | :value="item.id">{{ item.name }}</el-option> |
| | | </el-select> |
| | | <span v-else>{{ scope.row.name }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="夿³¨" prop="code"> |
| | | <template #default="scope"> |
| | | <el-select v-if="scope.row.isEdit" v-model="scope.row.checkProjectId" style="width: 100%;"> |
| | | <el-option v-for="(item, index) in options" :key="index" :label="item.remark" |
| | | :value="item.id">{{ item.remark }}</el-option> |
| | | </el-select> |
| | | <span v-else>{{ scope.row.remark }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="ç¹æ£å¨æ" prop="code"> |
| | | <template #default="scope"> |
| | | <el-input-number v-model="scope.row.intervalTime" v-if="scope.row.isEdit" :min="0" /> |
| | | <span v-else>{{ scope.row.intervalTime }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="æä½" prop="state" width="120"> |
| | | <template #default="scope"> |
| | | <el-button-group> |
| | | <el-button v-show="!scope.row.id || scope.row.isEdit" text type="primary" size="small" |
| | | @click="addCheck(scope.row)">ä¿å</el-button> |
| | | <el-button v-show="!scope.row.id || scope.row.isEdit" text type="primary" size="small" |
| | | @click="cancelCheck(scope.row, scope.$index)">åæ¶</el-button> |
| | | <el-popconfirm width="220" title="ç¡®å®å°éæ©çæ°æ®å é¤" @confirm="delCheck(scope.row)"> |
| | | <template #reference> |
| | | <el-button v-show="!scope.row.isEdit" text type="primary" |
| | | size="small">å é¤</el-button> |
| | | </template> |
| | | </el-popconfirm> |
| | | </el-button-group> |
| | | |
| | | </template> |
| | | </el-table-column> |
| | | </scFormTable> |
| | | <p style="margin: 10px 0;">ç¹æ£é¡¹</p> |
| | | <el-table :data="tableDataList" style="width: 100%; margin-bottom: 20px" row-key="id" border |
| | | default-expand-all> |
| | | <el-table-column prop="name" label="ç¹æ£é¡¹åç§°" /> |
| | | <el-table-column prop="valueType" label="æ°å¼ç±»å" /> |
| | | <el-table-column prop="requirement" label="ç¹æ£è¦æ±" /> |
| | | <el-table-column prop="standardValue" label="æ åæ°å¼" /> |
| | | </el-table> |
| | | </scDialog> |
| | | <!-- ä¿å
»é¡¹ç® --> |
| | | <scDialog v-model="visibleMaintain"> |
| | | <scFormTable ref="table1" v-model="talbeDataM" stripe hideDelete :addTemplate="addTemplateM" |
| | | @row-click="getMlistChild"> |
| | | <el-table-column label="ä¿å
»é¡¹ç®ç¼å·" prop="code"> |
| | | <template #default="scope"> |
| | | <el-input v-if="scope.row.isEdit" v-model="scope.row.code"></el-input> |
| | | <span v-else>{{ scope.row.code }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="ä¿å
»é¡¹ç®åç§°" prop="deviceTypeName"> |
| | | <template #default="scope"> |
| | | <el-input v-if="scope.row.isEdit" v-model="scope.row.deviceTypeName"></el-input> |
| | | <span v-else>{{ scope.row.deviceTypeName }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="ä¿å
»å¨æï¼å¤©ï¼" prop="intervalTime"> |
| | | <template #default="scope"> |
| | | <el-input-number style="width: 120px" v-model="scope.row.intervalTime" v-if="scope.row.isEdit" |
| | | :min="0" /> |
| | | <span v-else>{{ scope.row.intervalTime }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="ä¿å
»é¢è¦æç¤ºï¼å¤©ï¼" prop="preWarningDays"> |
| | | <template #default="scope"> |
| | | <el-input-number style="width: 120px" v-model="scope.row.preWarningDays" v-if="scope.row.isEdit" |
| | | :min="0" /> |
| | | <span v-else>{{ scope.row.preWarningDays }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="夿³¨" prop="remark"> |
| | | <template #default="scope"> |
| | | <el-input v-if="scope.row.isEdit" v-model="scope.row.remark"></el-input> |
| | | <span v-else>{{ scope.row.remark }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="æä½" prop="state" width="120"> |
| | | <template #default="scope"> |
| | | <el-button-group> |
| | | <el-button v-show="!scope.row.id || scope.row.isEdit" text type="primary" size="small" |
| | | @click="addM(scope.row)">ä¿å</el-button> |
| | | <el-button v-show="!scope.row.id || scope.row.isEdit" text type="primary" size="small" |
| | | @click="cancelCheck(scope.row, scope.$index)">åæ¶</el-button> |
| | | <el-popconfirm width="220" title="ç¡®å®å°éæ©çæ°æ®å é¤" @confirm="delM(scope.row)"> |
| | | <template #reference> |
| | | <el-button v-show="!scope.row.isEdit" text type="primary" |
| | | size="small">å é¤</el-button> |
| | | </template> |
| | | </el-popconfirm> |
| | | </el-button-group> |
| | | |
| | | </template> |
| | | </el-table-column> |
| | | </scFormTable> |
| | | <p style="margin: 10px 0"> |
| | | ä¿å
»é¡¹ |
| | | <el-button @click="addMC">æ·»å </el-button> |
| | | </p> |
| | | <el-table :data="talbeDataMChild" style="width: 100%; margin-bottom: 20px" row-key="id" border |
| | | default-expand-all> |
| | | <el-table-column prop="itemCode" label="ä¿å
»é¡¹ç¼å·" /> |
| | | <el-table-column prop="itemName" label="ä¿å
»é¡¹åç§°" /> |
| | | <el-table-column prop="itemRequirement" label="ä¿å
»è¦æ±" /> |
| | | <el-table-column prop="itemRemark" label="夿³¨" /> |
| | | <el-table-column label="æä½" prop="state" width="120"> |
| | | <template #default="scope"> |
| | | <el-button-group> |
| | | <el-popconfirm width="220" title="ç¡®å®å°éæ©çæ°æ®å é¤" @confirm="delMChild(scope.row)"> |
| | | <template #reference> |
| | | <el-button text type="primary" size="small">å é¤</el-button> |
| | | </template> |
| | | </el-popconfirm> |
| | | </el-button-group> |
| | | |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </scDialog> |
| | | <scDialog v-model="visibleAdd"> |
| | | <el-select v-model="itemId" style="width: 100%;"> |
| | | <el-option v-for=" (item, index) in options1" :key="index" :label="item.code" :value="item.id">{{ |
| | | item.code |
| | | }}</el-option> |
| | | </el-select> |
| | | <template #footer> |
| | | <div> |
| | | <el-button type="primary" @click="saveAdd">ç¡®å®</el-button> |
| | | </div> |
| | | </template> |
| | | |
| | | </scDialog> |
| | | </el-conatiner> |
| | | </template> |
| | | |
| | | <script> |
| | | import importTable from '@/layout/components/importTable.vue' |
| | | export default { |
| | | components: { |
| | | importTable, |
| | | }, |
| | | data() { |
| | | return { |
| | | params: { |
| | | keyWord: '', |
| | | status: 1, |
| | | }, |
| | | exportUrlTpl: '/api/blade-cps/device-types/export/template', |
| | | uploadUrl: '/api/blade-cps/device-types/excel/import', |
| | | visible: false, |
| | | config: { |
| | | labelWidth: 120, |
| | | formItems: [ |
| | | { |
| | | component: 'input', |
| | | label: 'æºå¨ç±»åç¼å·', |
| | | name: 'code', |
| | | options: { |
| | | placeholder: '', |
| | | maxlength: 100, |
| | | } |
| | | }, |
| | | { |
| | | component: 'input', |
| | | label: 'æºå¨ç±»ååç§°', |
| | | name: 'name', |
| | | options: { |
| | | multiple: false, |
| | | data: [] |
| | | }, |
| | | disabled: false |
| | | }, |
| | | { |
| | | component: 'input', |
| | | label: '夿³¨', |
| | | name: 'remark', |
| | | type: 'textarea', |
| | | options: { |
| | | multiple: false, |
| | | data: [] |
| | | }, |
| | | disabled: false |
| | | }, |
| | | { |
| | | component: 'select', |
| | | label: 'ç¶æ', |
| | | name: 'status', |
| | | options: { |
| | | multiple: false, |
| | | items: [ |
| | | { |
| | | value: 1, |
| | | label: 'å¯ç¨' |
| | | }, |
| | | { |
| | | value: 0, |
| | | label: 'åç¨' |
| | | }, |
| | | ] |
| | | }, |
| | | disabled: false |
| | | } |
| | | ] |
| | | }, |
| | | rules: { |
| | | code: [ |
| | | { required: true, message: '请è¾å
¥' }, |
| | | ], |
| | | name: [ |
| | | { required: true, message: '请è¾å
¥' }, |
| | | ] |
| | | }, |
| | | form: {}, |
| | | apiObj: { |
| | | get: async (data) => { |
| | | let params = { |
| | | ...data, |
| | | ...this.params |
| | | } |
| | | return await this.$HTTP.get(`/api/blade-cps/device-types/page`, {}, { params }).then(res => { |
| | | res.data.records = res?.data?.records.map(v => { |
| | | return { |
| | | ...v, |
| | | statusName: v.status ? 'å¯ç¨' : 'ç¦ç¨' |
| | | } |
| | | }) |
| | | return res |
| | | }) |
| | | } |
| | | }, |
| | | selection: [], |
| | | visibleCheck: false, |
| | | selectRow: {}, |
| | | options: [], |
| | | tabledata: [], |
| | | addTemplate: { |
| | | checkProjectId: '', |
| | | intervalTime: '', |
| | | isEdit: true |
| | | }, |
| | | tableDataList: [], |
| | | // baoyang |
| | | visibleMaintain: false, |
| | | addTemplateM: { |
| | | isEdit: true, |
| | | }, |
| | | talbeDataM: [], |
| | | talbeDataMChild: [], |
| | | options1: [], |
| | | visibleAdd: false, |
| | | itemId: '', |
| | | selectMRow: {} |
| | | } |
| | | }, |
| | | created() { |
| | | this.init() |
| | | }, |
| | | methods: { |
| | | init() { |
| | | this.$HTTP.get(`/api/blade-cps/check-project/page?key=¤t=1&size=-1`).then(res => { |
| | | this.options = res.data.records |
| | | }) |
| | | this.$HTTP.get(`/api/blade-cps/maintain-item/list?keyWord=`).then(res => { |
| | | this.options1 = res.data |
| | | }) |
| | | }, |
| | | handleSelectionChange(selection) { |
| | | this.selection = selection |
| | | }, |
| | | addNew() { |
| | | this.config.formItems[0].disabled = false |
| | | this.form = { |
| | | status: 1, |
| | | } |
| | | this.visible = true |
| | | }, |
| | | exportData() { |
| | | this.$HTTP.post(`/api/blade-cps/device-types/excel/export`, {}, { params: this.params }).then(res => { |
| | | if (res.success) { |
| | | window.open(res.data.link) |
| | | } |
| | | }) |
| | | }, |
| | | search() { |
| | | this.$refs.table.reload() |
| | | }, |
| | | table_del(selection, type) { |
| | | this.$HTTP.delete(`/api/blade-cps/device-types?type=${type}`, {}, { |
| | | data: { |
| | | idList: selection.map(v => v.id), |
| | | } |
| | | }).then(res => { |
| | | if (res.success) { |
| | | this.search() |
| | | } else { |
| | | this.$message.error(res.msg) |
| | | } |
| | | }) |
| | | }, |
| | | table_edit(row) { |
| | | this.config.formItems[0].disabled = true |
| | | this.form = { |
| | | ...row |
| | | } |
| | | this.visible = true |
| | | }, |
| | | submit() { |
| | | if (!this.form.id) { |
| | | this.$HTTP.post(`/api/blade-cps/device-types`, this.form).then(res => { |
| | | if (res.success) { |
| | | this.visible = false |
| | | this.search() |
| | | } |
| | | }) |
| | | } else { |
| | | this.$HTTP.put(`/api/blade-cps/device-types`, this.form).then(res => { |
| | | if (res.success) { |
| | | this.visible = false |
| | | this.search() |
| | | } |
| | | }) |
| | | } |
| | | |
| | | }, |
| | | viewCheck(row) { |
| | | this.selectRow = row |
| | | |
| | | this.getCheckList().then(res => { |
| | | this.visibleCheck = true |
| | | this.tableDataList = [] |
| | | }) |
| | | }, |
| | | getCheckList() { |
| | | let row = this.selectRow |
| | | return this.$HTTP.get(`/api/blade-cps/device-type-check-projects/page?id=${row.id}`).then(res => { |
| | | if (res.success) { |
| | | this.tabledata = res.data |
| | | this.getCheckListChild(this.tabledata[0]) |
| | | } else { |
| | | this.tabledata = [] |
| | | } |
| | | }) |
| | | }, |
| | | getCheckListChild(row) { |
| | | if (!row?.checkProjectId) return this.tableDataList = [] |
| | | this.$HTTP.get(`/api/blade-cps/check-item/list?projectId=${row.checkProjectId}`).then(res => { |
| | | if (res.success) { |
| | | this.tableDataList = res.data |
| | | } else { |
| | | this.tableDataList = [] |
| | | } |
| | | }) |
| | | }, |
| | | changeCheck(val) { |
| | | this.getCheckListChild({ checkProjectId: val }) |
| | | }, |
| | | cancelCheck(row, index) { |
| | | row.isEdit = false |
| | | this.tabledata.splice(index, 1) |
| | | }, |
| | | delCheck(row) { |
| | | this.$HTTP.delete(`/api/blade-cps/device-type-check-projects`, {}, { |
| | | data: { |
| | | ids: [row.id] |
| | | } |
| | | }).then(res => { |
| | | if (res.success) { |
| | | this.getCheckList() |
| | | } |
| | | }) |
| | | }, |
| | | addCheck(row) { |
| | | this.$HTTP.post(`/api/blade-cps/device-type-check-projects`, { |
| | | deviceTypeId: this.selectRow.id, |
| | | checkProjectId: [row.checkProjectId], |
| | | intervalTime: row.intervalTime |
| | | }).then(res => { |
| | | if (res.success) { |
| | | this.getCheckList() |
| | | } else { |
| | | this.$message.error(res.msg) |
| | | } |
| | | }) |
| | | }, |
| | | // ä¿å
» |
| | | viewM(row) { |
| | | this.selectRow = row |
| | | this.getMList().then(res => { |
| | | this.visibleMaintain = true |
| | | this.tableDataList = [] |
| | | }) |
| | | }, |
| | | getMList() { |
| | | return this.$HTTP.get(`/api/blade-cps/maintain-project/list?deviceTypeId=${this.selectRow.id}`).then(res => { |
| | | if (res.success) { |
| | | this.talbeDataM = res.data |
| | | this.getMlistChild(this.talbeDataM?.[0]) |
| | | } else { |
| | | this.talbeDataM = [] |
| | | } |
| | | }) |
| | | }, |
| | | getMlistChild(row) { |
| | | this.selectMRow = row |
| | | if (!row?.id) return this.talbeDataMChild = [] |
| | | this.$HTTP.get(`/api/blade-cps/maintain-project-item/item-list?projectId=${row.id}`).then(res => { |
| | | if (res) { |
| | | this.talbeDataMChild = res |
| | | } else { |
| | | this.talbeDataMChild = [] |
| | | } |
| | | }) |
| | | }, |
| | | // |
| | | addM(row) { |
| | | this.$HTTP.post(`/api/blade-cps/maintain-project/create-maintain-project`, { |
| | | code: row.code, |
| | | deviceTypeId: this.selectRow.id, |
| | | deviceTypeName: row.deviceTypeName, |
| | | name: row.deviceTypeName, |
| | | intervalTime: row.intervalTime, |
| | | preWarningDays: row.preWarningDays, |
| | | remark: row.remark |
| | | }).then(res => { |
| | | if (res.success) { |
| | | this.getMList() |
| | | } else { |
| | | this.$message.error(res.msg) |
| | | } |
| | | }) |
| | | }, |
| | | delM(row) { |
| | | this.$HTTP.post(`/api/blade-cps/maintain-project/delete-maintain-project`, {}, { |
| | | params: { |
| | | id: row.id |
| | | } |
| | | }).then(res => { |
| | | if (res.success) { |
| | | this.getMList() |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | delMChild(row) { |
| | | this.$HTTP.post(`/api/blade-cps/maintain-project-item/delete-maintain-project-item?id=${row.id}`).then(res => { |
| | | if (res.success) { |
| | | this.getMlistChild(this.selectMRow) |
| | | } else { |
| | | this.$message.errror(res.msg) |
| | | } |
| | | }) |
| | | }, |
| | | addMC() { |
| | | this.itemId = '' |
| | | this.visibleAdd = true |
| | | }, |
| | | saveAdd() { |
| | | this.$HTTP.post(`/api/blade-cps/maintain-project-item/create-maintain-project-item`, { |
| | | itemId: this.itemId, |
| | | projectId: this.selectMRow.id |
| | | }).then(res => { |
| | | if (res.success) { |
| | | this.visibleAdd = false |
| | | this.getMlistChild(this.selectMRow) |
| | | } else { |
| | | this.$message.errror(res.msg) |
| | | } |
| | | }) |
| | | } |
| | | }, |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" scoped></style> |