| | |
| | | <template> |
| | | <div class="mod-taskReliability-operatConditModel}"> |
| | | <zt-table-wraper ref="tableObj" :paging='false' defaultNotQuery="true" query-url="/taskReliability/OperatConditModel/page" delete-url="/taskReliability/OperatConditModel/" v-slot="{ table }"> |
| | | <el-form :inline="true" :model="dataForm" @keyup.enter.native="table.query()"> |
| | | <el-form-item> |
| | | </el-form-item> |
| | | </el-form> |
| | | <el-table v-loading="table.dataLoading" :data="table.dataList" height="100px" |
| | | v-adaptive="{bottomOffset:70}" border @selection-change="table.selectionChangeHandle" |
| | | row-key="id" |
| | | :tree-props="{children: 'children', hasChildren: 'hasChildren'}" |
| | | :default-expand-all="true"> |
| | | <el-table-column prop="product" label="产品节点" width="160"/> |
| | | <el-table-column prop="modelName" label="产品模型"/> |
| | | <zt-table-column-handle :table="table" edit-perm="taskReliability:update" |
| | | delete-perm="taskReliability::delete" :has-view="false"> |
| | | <template v-slot="{ row }"> |
| | | <zt-table-button @click="openSelectModel(row)">选择模型</zt-table-button> |
| | | </template> |
| | | </zt-table-column-handle> |
| | | </el-table> |
| | | <select-model-rbd ref="SelectModelRbd" ></select-model-rbd> |
| | | </zt-table-wraper> |
| | | </div> |
| | | <div class="mod-taskReliability-operatConditModel}"> |
| | | <zt-table-wraper @dataLoaded="dataLoaded" ref="tableObj" :paging='false' defaultNotQuery="true" |
| | | query-url="/taskReliability/OperatConditModel/page" |
| | | delete-url="/taskReliability/OperatConditModel/" v-slot="{ table }"> |
| | | <el-form :inline="true" :model="dataForm" @keyup.enter.native="table.query()"> |
| | | <el-form-item> |
| | | <el-button v-if="dataForm.productId" type="primary" @click="save()">保存</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | <el-table v-loading="table.dataLoading" :data="table.dataList" height="100px" |
| | | v-adaptive="{bottomOffset:70}" border @selection-change="table.selectionChangeHandle" |
| | | row-key="iid" |
| | | :tree-props="{children: 'children', hasChildren: 'hasChildren'}" |
| | | :default-expand-all="true"> |
| | | <el-table-column prop="productName" label="产品节点"/> |
| | | <el-table-column prop="modelId" label="产品模型"> |
| | | <template slot-scope="scope"> |
| | | <el-select v-model="scope.row.modelId" :disabled="scope.row.isDisabled == 1" placeholder="请选择" |
| | | style="width:100%" @change="modelChanged(scope.row)"> |
| | | <el-option on |
| | | v-for="item in scope.row.modelList" |
| | | :key="item.id" |
| | | :label="item.modelName" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="操作" width="100px"> |
| | | <template v-slot="{ row }"> |
| | | <el-button v-if="row.modelId" type="primary" size="small" @click="drawRBD(row)">查看模型</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <el-dialog v-dialogDrag title="模型设计" top="1vh" width='95%' :visible.sync="dialogVisible2" v-if="dialogVisible2"> |
| | | <RBDEditImg ref="rbdEditImg"></RBDEditImg> |
| | | </el-dialog> |
| | | </zt-table-wraper> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import SelectModelRbd from "./SelectModelRbd"; |
| | | import RBDEditImg from './RBD-edit-img' |
| | | import cloneDeep from 'lodash/cloneDeep' |
| | | |
| | | export default { |
| | | name: 'OperaConditModel', |
| | | data() { |
| | | return { |
| | | dataForm: { |
| | | operatConditId:'', |
| | | productId:'', |
| | | } |
| | | id: '', |
| | | operatConditId: '', |
| | | productId: '', |
| | | }, |
| | | mapModelNodes: {}, |
| | | modelList: [], |
| | | dialogVisible2: false, |
| | | isChange: false, |
| | | } |
| | | }, |
| | | components: { |
| | | SelectModelRbd |
| | | RBDEditImg |
| | | }, |
| | | methods:{ |
| | | mounted() { |
| | | this.getModelNodes() |
| | | }, |
| | | methods: { |
| | | init(param) { |
| | | console.log(param, '') |
| | | this.dataForm.operatConditId = param.row.id |
| | | this.dataForm.productId = param.productId |
| | | this.$refs.tableObj.query() |
| | | }, |
| | | openSelectModel(row) { |
| | | console.log(row, 'selectModel'); |
| | | if (!row.operatConditId) |
| | | row.operatConditId = this.dataForm.operatConditId |
| | | this.$refs.SelectModelRbd.$refs.dialog.init(row) |
| | | dataLoaded(dataList) { |
| | | dataList[0].isDisabled = 0 |
| | | if (!dataList[0].modelId && dataList[0].modelList.length == 1) { |
| | | console.log(dataList[0].modelList[0].id, ' dataList[0].modelList[0].modelId') |
| | | dataList[0].modelId = dataList[0].modelList[0].id |
| | | console.log(dataList[0], 'dataLoaded(dataList)') |
| | | this.modelChangedProess(dataList[0]) |
| | | } |
| | | }, |
| | | async save() { |
| | | let res = await this.$http.post('/taskReliability/OperatConditModel/', this.$refs.tableObj.dataList[0]) |
| | | if (res.success) { |
| | | this.isChange = false |
| | | this.$refs.tableObj.query() |
| | | } |
| | | }, |
| | | async getModelNodes() { |
| | | let res = await this.$http.get(`/taskReliability/OperatConditModel/getModelNodes?shipId=0`) |
| | | console.log(res, 'res taskReliability') |
| | | console.log(res.data, 'res.data taskReliability') |
| | | if (res.data) { |
| | | this.mapModelNodes = res.data |
| | | |
| | | } |
| | | }, |
| | | modelChanged(row) { |
| | | this.isChange = true |
| | | this.modelChangedProess(row) |
| | | }, |
| | | modelChangedProess(row) { |
| | | let modelId = row.modelId |
| | | let modelNodes = this.mapModelNodes[modelId] |
| | | console.log(modelId, 'modelChanged modelId') |
| | | console.log(modelNodes, 'modelChanged modelNodes') |
| | | |
| | | for (let subRow of row.children) { |
| | | if (modelNodes.indexOf(subRow.productId)) { |
| | | subRow.isDisabled = 0 |
| | | if (subRow.modelList.length == 1) { |
| | | subRow.modelId = subRow.modelList[0].id |
| | | } else { |
| | | //subRow.modelId = null |
| | | } |
| | | } else { |
| | | subRow.isDisabled = 1 |
| | | subRow.modelId = null |
| | | } |
| | | this.nodeIteration(subRow) |
| | | } |
| | | }, |
| | | nodeIteration(parentRow) { |
| | | for (let subRow of parentRow.children) { |
| | | if (parentRow.modelId) { |
| | | subRow.isDisabled = 0 |
| | | if (subRow.modelList.length == 1) { |
| | | subRow.modelId = subRow.modelList[0].id |
| | | } |
| | | } else { |
| | | subRow.isDisabled = 1 |
| | | subRow.modelId = null |
| | | } |
| | | this.nodeIteration(subRow) |
| | | } |
| | | }, |
| | | drawRBD(row) { |
| | | this.dialogVisible2 = true |
| | | let param = { |
| | | id: row.modelId, |
| | | model: row.modelName, |
| | | productId: row.productId |
| | | } |
| | | this.$nextTick(() => { |
| | | this.$refs.rbdEditImg.init(param) |
| | | }) |
| | | } |
| | | } |
| | | } |