|
|
|
@ -9,7 +9,7 @@ |
|
|
|
<el-select v-model="searchData.baseData" placeholder="请选择" style="width: 90px"> |
|
|
|
<el-option label="全部" value=""></el-option> |
|
|
|
<el-option label="控制" value="控制"></el-option> |
|
|
|
<el-option label="未控制" value="控制"></el-option> |
|
|
|
<el-option label="未控制" value="未控制"></el-option> |
|
|
|
</el-select> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="控制方式"> |
|
|
|
@ -21,6 +21,7 @@ |
|
|
|
</el-form-item> |
|
|
|
<el-form-item :label="' '"> |
|
|
|
<el-button type="primary" @click="getDataList()">查询</el-button> |
|
|
|
<el-button type="primary" @click="addModal()">新增</el-button> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item :label="' '"> |
|
|
|
<download-excel |
|
|
|
@ -77,10 +78,16 @@ |
|
|
|
</el-table> |
|
|
|
|
|
|
|
<!-- 检验模板新增/修改 --> |
|
|
|
<el-dialog title="控制维护" :close-on-click-modal="false" v-drag :visible.sync="modalFlag" width="430px"> |
|
|
|
<el-dialog :title="modalData.flag === '1' ? '新增控制' : '控制维护'" :close-on-click-modal="false" v-drag :visible.sync="modalFlag" width="780px"> |
|
|
|
<el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;"> |
|
|
|
<el-form-item label="编码:"> |
|
|
|
<el-input v-model="modalData.controlNo" :disabled="modalData.flag !== '1'" style="width: 160px"></el-input> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="类型:"> |
|
|
|
<el-input v-model="modalData.type" style="width: 200px"></el-input> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="控制内容:"> |
|
|
|
<el-input v-model="modalData.baseDesc" :disabled="modalDisableFlag" style="width: 387px"></el-input> |
|
|
|
<el-input v-model="modalData.baseDesc" style="width: 330px"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-form> |
|
|
|
<el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;"> |
|
|
|
@ -91,22 +98,85 @@ |
|
|
|
</el-select> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="参数一:"> |
|
|
|
<el-input v-model="modalData.thirdType" style="width: 120px"></el-input> |
|
|
|
<el-input v-model="modalData.thirdType" style="width: 280px"></el-input> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="参数二:"> |
|
|
|
<el-input v-model="modalData.secondType" style="width: 120px"></el-input> |
|
|
|
<el-input v-model="modalData.secondType" style="width: 280px"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-form> |
|
|
|
<el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;"> |
|
|
|
<el-form-item label="备注:"> |
|
|
|
<el-input v-model="modalData.remark" style="width: 387px"></el-input> |
|
|
|
<el-input v-model="modalData.remark" style="width: 730px"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-form> |
|
|
|
<div style="margin: 0 7px 8px;"> |
|
|
|
<div style="font-weight: 600;">可用维度</div> |
|
|
|
<el-checkbox-group v-model="selectedDimensionCodes" @change="onDimensionChecked"> |
|
|
|
<el-checkbox v-for="item in dimensionCatalog" :key="item.dimensionCode" :label="item.dimensionCode">{{ item.dimensionName }}</el-checkbox> |
|
|
|
</el-checkbox-group> |
|
|
|
</div> |
|
|
|
<div style="margin: 0 7px;"> |
|
|
|
<div style="font-weight: 600;">生效范围</div> |
|
|
|
<div style="color: #909399; font-size: 12px; margin-bottom: 6px;">先勾选本控制要使用的维度。不配置生效范围时,开关打开即对全部生效。同一维度只能选择包含或不包含。</div> |
|
|
|
<el-table class="scope-table" :data="scopeGroups" border size="mini"> |
|
|
|
<el-table-column label="维度" width="150"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<el-select v-model="scope.row.dimensionCode" placeholder="请选择" @change="onDimensionChange(scope.row)"> |
|
|
|
<el-option v-for="item in dimensionOptions(scope.row)" :key="item.dimensionCode" :label="item.dimensionName" :value="item.dimensionCode"></el-option> |
|
|
|
</el-select> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column label="条件" width="120"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<el-select v-model="scope.row.matchType" placeholder="请选择"> |
|
|
|
<el-option label="包含" value="包含"></el-option> |
|
|
|
<el-option label="不包含" value="不包含"></el-option> |
|
|
|
</el-select> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column label="参数"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<el-tag v-for="(val, index) in scope.row.values" :key="val.valueCode" closable size="small" style="margin: 2px" @close="scope.row.values.splice(index, 1)">{{ val.valueName || val.valueCode }}</el-tag> |
|
|
|
<el-button type="text" :disabled="!scope.row.dimensionCode" @click="openValueDialog(scope.row)">选择</el-button> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column label="操作" width="70" align="center"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<el-button type="text" @click="scopeGroups.splice(scope.$index, 1)">删除</el-button> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
</el-table> |
|
|
|
<el-button type="primary" plain size="mini" style="margin-top: 8px" :disabled="selectedDimensionCodes.length === 0 || scopeGroups.length >= selectedDimensionCodes.length" @click="addScopeGroup">添加条件</el-button> |
|
|
|
</div> |
|
|
|
<el-footer style="height:40px;margin-top: 10px;text-align:center"> |
|
|
|
<el-button type="primary" @click="saveData()">保存</el-button> |
|
|
|
<el-button type="primary" @click="modalFlag = false">关闭</el-button> |
|
|
|
</el-footer> |
|
|
|
</el-dialog> |
|
|
|
|
|
|
|
<el-dialog title="选择参数" :close-on-click-modal="false" v-drag :visible.sync="valueDialogFlag" width="760px" append-to-body> |
|
|
|
<el-input v-model="valueKeyword" placeholder="编码或名称" style="width: 220px" @keyup.enter.native="searchDimensionValue(true)"></el-input> |
|
|
|
<el-button type="primary" @click="searchDimensionValue(true)">查询</el-button> |
|
|
|
<el-table ref="valueTable" :data="valueList" row-key="valueCode" border height="360" style="margin-top: 8px" @selection-change="valueSelectionChange"> |
|
|
|
<el-table-column type="selection" reserve-selection width="45"></el-table-column> |
|
|
|
<el-table-column prop="valueCode" label="编码" min-width="160"></el-table-column> |
|
|
|
<el-table-column prop="valueName" label="名称" min-width="220"></el-table-column> |
|
|
|
</el-table> |
|
|
|
<el-pagination |
|
|
|
style="margin-top: 8px" |
|
|
|
@size-change="valueSizeChange" |
|
|
|
@current-change="valueCurrentChange" |
|
|
|
:current-page="valuePageIndex" |
|
|
|
:page-sizes="[20, 50, 100]" |
|
|
|
:page-size="valuePageSize" |
|
|
|
:total="valueTotal" |
|
|
|
layout="total, sizes, prev, pager, next"> |
|
|
|
</el-pagination> |
|
|
|
<el-footer style="height:40px;margin-top: 10px;text-align:center"> |
|
|
|
<el-button type="primary" @click="confirmValues">确定</el-button> |
|
|
|
<el-button @click="valueDialogFlag = false">关闭</el-button> |
|
|
|
</el-footer> |
|
|
|
</el-dialog> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
|
|
|
|
@ -114,7 +184,9 @@ |
|
|
|
import { |
|
|
|
sysControlModelSearch, // 列表查询 |
|
|
|
controlData, // 控制 |
|
|
|
sysControlModelSave, |
|
|
|
sysControlModelUpdate, // 编辑 |
|
|
|
searchControlDimensionValue, |
|
|
|
} from "@/api/base.js" |
|
|
|
import {userFavoriteList, saveUserFavorite, removeUserFavorite} from '@/api/userFavorite.js' |
|
|
|
export default { |
|
|
|
@ -152,8 +224,28 @@ export default { |
|
|
|
thirdType: '', |
|
|
|
secondType: '', |
|
|
|
controlStyle: '', |
|
|
|
parameterTable: '' |
|
|
|
parameterTable: '', |
|
|
|
scopeList: [] |
|
|
|
}, |
|
|
|
dimensionCatalog: [ |
|
|
|
{ dimensionCode: 'PART', dimensionName: '物料' }, |
|
|
|
{ dimensionCode: 'WORK_CENTER', dimensionName: '加工中心' }, |
|
|
|
{ dimensionCode: 'RESOURCE', dimensionName: '机台' }, |
|
|
|
{ dimensionCode: 'OPERATION', dimensionName: '工序' }, |
|
|
|
{ dimensionCode: 'INSPECTION_TYPE', dimensionName: '检验类型' }, |
|
|
|
{ dimensionCode: 'PERSON', dimensionName: '人员' } |
|
|
|
], |
|
|
|
selectedDimensionCodes: [], |
|
|
|
dimensionList: [], |
|
|
|
scopeGroups: [], |
|
|
|
valueDialogFlag: false, |
|
|
|
valueKeyword: '', |
|
|
|
valueList: [], |
|
|
|
valueSelection: [], |
|
|
|
valuePageIndex: 1, |
|
|
|
valuePageSize: 20, |
|
|
|
valueTotal: 0, |
|
|
|
currentScopeRow: null, |
|
|
|
// 检验项目展示标头 |
|
|
|
columnList: [ |
|
|
|
{ |
|
|
|
@ -204,6 +296,18 @@ export default { |
|
|
|
status: true, |
|
|
|
fixed: '', |
|
|
|
}, |
|
|
|
{ |
|
|
|
columnProp: 'scopeDesc', |
|
|
|
headerAlign: 'center', |
|
|
|
align: 'left', |
|
|
|
columnLabel: '生效范围', |
|
|
|
columnHidden: false, |
|
|
|
columnImage: false, |
|
|
|
columnSortable: false, |
|
|
|
sortLv: 0, |
|
|
|
status: true, |
|
|
|
fixed: '', |
|
|
|
}, |
|
|
|
{ |
|
|
|
columnProp: 'thirdType', |
|
|
|
headerAlign: 'center', |
|
|
|
@ -317,9 +421,34 @@ export default { |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
addModal () { |
|
|
|
this.modalData = { |
|
|
|
flag: '1', |
|
|
|
controlNo: '', |
|
|
|
site: this.$store.state.user.site, |
|
|
|
updateBy: this.$store.state.user.name, |
|
|
|
createBy: this.$store.state.user.name, |
|
|
|
type: '', |
|
|
|
baseData: '未控制', |
|
|
|
baseDesc: '', |
|
|
|
status: 1, |
|
|
|
remark: '', |
|
|
|
thirdType: '', |
|
|
|
secondType: '', |
|
|
|
controlStyle: '强制', |
|
|
|
parameterTable: 'N', |
|
|
|
scopeList: [] |
|
|
|
} |
|
|
|
this.selectedDimensionCodes = [] |
|
|
|
this.dimensionList = [] |
|
|
|
this.scopeGroups = [] |
|
|
|
this.modalFlag = true |
|
|
|
}, |
|
|
|
|
|
|
|
// 编辑 |
|
|
|
updateModal (row) { |
|
|
|
this.modalData = { |
|
|
|
flag: '2', |
|
|
|
controlNo: row.controlNo, |
|
|
|
site: this.$store.state.user.site, |
|
|
|
updateBy: this.$store.state.user.name, |
|
|
|
@ -331,21 +460,197 @@ export default { |
|
|
|
thirdType: row.thirdType, |
|
|
|
secondType: row.secondType, |
|
|
|
controlStyle: row.controlStyle, |
|
|
|
parameterTable: row.parameterTable |
|
|
|
parameterTable: row.parameterTable, |
|
|
|
scopeList: row.scopeList || [] |
|
|
|
} |
|
|
|
this.modalDisableFlag = true |
|
|
|
this.dimensionList = row.dimensionList || [] |
|
|
|
this.selectedDimensionCodes = this.dimensionList.map(item => item.dimensionCode) |
|
|
|
this.scopeGroups = this.buildScopeGroups(row.scopeList) |
|
|
|
this.modalFlag = true |
|
|
|
}, |
|
|
|
|
|
|
|
onDimensionChecked () { |
|
|
|
this.dimensionList = this.dimensionCatalog.filter(item => this.selectedDimensionCodes.indexOf(item.dimensionCode) >= 0) |
|
|
|
this.scopeGroups = this.scopeGroups.filter(group => this.selectedDimensionCodes.indexOf(group.dimensionCode) >= 0) |
|
|
|
}, |
|
|
|
|
|
|
|
buildScopeGroups (list) { |
|
|
|
const nameMap = {} |
|
|
|
this.dimensionList.forEach(item => { |
|
|
|
nameMap[item.dimensionCode] = item.dimensionName |
|
|
|
}) |
|
|
|
const groups = [] |
|
|
|
const index = {} |
|
|
|
;(list || []).forEach(row => { |
|
|
|
if (index[row.dimensionCode] == null) { |
|
|
|
index[row.dimensionCode] = groups.length |
|
|
|
groups.push({ |
|
|
|
dimensionCode: row.dimensionCode, |
|
|
|
dimensionName: row.dimensionName || nameMap[row.dimensionCode] || row.dimensionCode, |
|
|
|
matchType: row.matchType || '包含', |
|
|
|
values: [] |
|
|
|
}) |
|
|
|
} |
|
|
|
if (row.valueCode) { |
|
|
|
groups[index[row.dimensionCode]].values.push({ |
|
|
|
valueCode: row.valueCode, |
|
|
|
valueName: row.valueName || row.valueCode |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
return groups |
|
|
|
}, |
|
|
|
|
|
|
|
dimensionOptions (row) { |
|
|
|
const used = this.scopeGroups |
|
|
|
.filter(item => item !== row && item.dimensionCode) |
|
|
|
.map(item => item.dimensionCode) |
|
|
|
return this.dimensionList.filter(item => used.indexOf(item.dimensionCode) < 0 || item.dimensionCode === row.dimensionCode) |
|
|
|
}, |
|
|
|
|
|
|
|
onDimensionChange (row) { |
|
|
|
const dimension = this.dimensionList.find(item => item.dimensionCode === row.dimensionCode) |
|
|
|
row.dimensionName = dimension ? dimension.dimensionName : row.dimensionCode |
|
|
|
row.values = [] |
|
|
|
}, |
|
|
|
|
|
|
|
addScopeGroup () { |
|
|
|
this.scopeGroups.push({ |
|
|
|
dimensionCode: '', |
|
|
|
dimensionName: '', |
|
|
|
matchType: '包含', |
|
|
|
values: [] |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
openValueDialog (row) { |
|
|
|
this.currentScopeRow = row |
|
|
|
this.valueKeyword = '' |
|
|
|
this.valueList = [] |
|
|
|
this.valueSelection = [] |
|
|
|
this.valuePageIndex = 1 |
|
|
|
this.valuePageSize = 20 |
|
|
|
this.valueTotal = 0 |
|
|
|
this.valueDialogFlag = true |
|
|
|
this.$nextTick(() => { |
|
|
|
if (this.$refs.valueTable) { |
|
|
|
this.$refs.valueTable.clearSelection() |
|
|
|
} |
|
|
|
}) |
|
|
|
this.searchDimensionValue(true) |
|
|
|
}, |
|
|
|
|
|
|
|
searchDimensionValue (resetPage) { |
|
|
|
if (!this.currentScopeRow || !this.currentScopeRow.dimensionCode) { |
|
|
|
return |
|
|
|
} |
|
|
|
if (resetPage) { |
|
|
|
this.valuePageIndex = 1 |
|
|
|
} |
|
|
|
searchControlDimensionValue({ |
|
|
|
site: this.$store.state.user.site, |
|
|
|
dimensionCode: this.currentScopeRow.dimensionCode, |
|
|
|
keyword: this.valueKeyword || '', |
|
|
|
page: this.valuePageIndex, |
|
|
|
limit: this.valuePageSize |
|
|
|
}).then(({data}) => { |
|
|
|
if (data && data.code === 0) { |
|
|
|
this.valueList = data.rows || [] |
|
|
|
this.valueTotal = data.total || 0 |
|
|
|
} else { |
|
|
|
this.$alert(data.msg, '错误', { confirmButtonText: '确定' }) |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
valueSizeChange (val) { |
|
|
|
this.valuePageSize = val |
|
|
|
this.valuePageIndex = 1 |
|
|
|
this.searchDimensionValue() |
|
|
|
}, |
|
|
|
|
|
|
|
valueCurrentChange (val) { |
|
|
|
this.valuePageIndex = val |
|
|
|
this.searchDimensionValue() |
|
|
|
}, |
|
|
|
|
|
|
|
valueSelectionChange (rows) { |
|
|
|
this.valueSelection = rows |
|
|
|
}, |
|
|
|
|
|
|
|
confirmValues () { |
|
|
|
if (!this.currentScopeRow) { |
|
|
|
return |
|
|
|
} |
|
|
|
const exists = {} |
|
|
|
this.currentScopeRow.values.forEach(item => { |
|
|
|
exists[item.valueCode] = true |
|
|
|
}) |
|
|
|
this.valueSelection.forEach(item => { |
|
|
|
if (!exists[item.valueCode]) { |
|
|
|
this.currentScopeRow.values.push({ |
|
|
|
valueCode: item.valueCode, |
|
|
|
valueName: item.valueName || item.valueCode |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
this.valueDialogFlag = false |
|
|
|
}, |
|
|
|
|
|
|
|
flattenScopeGroups () { |
|
|
|
const list = [] |
|
|
|
this.scopeGroups.forEach(group => { |
|
|
|
;(group.values || []).forEach(item => { |
|
|
|
list.push({ |
|
|
|
dimensionCode: group.dimensionCode, |
|
|
|
matchType: group.matchType, |
|
|
|
valueCode: item.valueCode, |
|
|
|
valueName: item.valueName |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
return list |
|
|
|
}, |
|
|
|
|
|
|
|
// 保存编辑 |
|
|
|
saveData () { |
|
|
|
if (this.modalData.flag === '1' && (this.modalData.controlNo === '' || this.modalData.controlNo == null)) { |
|
|
|
this.$alert('请输入编码!', '错误', { confirmButtonText: '确定' }) |
|
|
|
return false |
|
|
|
} |
|
|
|
if (this.modalData.baseDesc === '' || this.modalData.baseDesc == null) { |
|
|
|
this.$alert('请输入控制内容!', '错误', { confirmButtonText: '确定' }) |
|
|
|
return false |
|
|
|
} |
|
|
|
if (this.modalData.controlStyle === '' || this.modalData.controlStyle == null) { |
|
|
|
this.$alert('请选择控制方式!', '错误', { |
|
|
|
confirmButtonText: '确定' |
|
|
|
}) |
|
|
|
return false |
|
|
|
} |
|
|
|
sysControlModelUpdate(this.modalData).then(({data}) => { |
|
|
|
for (let i = 0; i < this.scopeGroups.length; i++) { |
|
|
|
const group = this.scopeGroups[i] |
|
|
|
if (!group.dimensionCode) { |
|
|
|
this.$alert('请选择控制维度!', '错误', { confirmButtonText: '确定' }) |
|
|
|
return false |
|
|
|
} |
|
|
|
if (!group.matchType) { |
|
|
|
this.$alert('请选择条件!', '错误', { confirmButtonText: '确定' }) |
|
|
|
return false |
|
|
|
} |
|
|
|
if (!group.values || group.values.length === 0) { |
|
|
|
this.$alert('请选择参数!', '错误', { confirmButtonText: '确定' }) |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
this.onDimensionChecked() |
|
|
|
this.modalData.dimensionList = this.dimensionList.map(item => ({ |
|
|
|
dimensionCode: item.dimensionCode, |
|
|
|
dimensionName: item.dimensionName |
|
|
|
})) |
|
|
|
this.modalData.scopeList = this.flattenScopeGroups() |
|
|
|
const request = this.modalData.flag === '1' ? sysControlModelSave : sysControlModelUpdate |
|
|
|
request(this.modalData).then(({data}) => { |
|
|
|
if (data && data.code === 0) { |
|
|
|
this.getDataList() |
|
|
|
this.modalFlag = false |
|
|
|
@ -441,3 +746,23 @@ export default { |
|
|
|
}, |
|
|
|
} |
|
|
|
</script> |
|
|
|
<style scoped> |
|
|
|
.scope-table /deep/ td { |
|
|
|
padding-top: 6px; |
|
|
|
padding-bottom: 6px; |
|
|
|
} |
|
|
|
.scope-table /deep/ .cell { |
|
|
|
height: auto !important; |
|
|
|
line-height: 28px !important; |
|
|
|
overflow: visible; |
|
|
|
white-space: normal; |
|
|
|
text-overflow: clip; |
|
|
|
} |
|
|
|
.scope-table /deep/ .el-select { |
|
|
|
width: 100%; |
|
|
|
} |
|
|
|
.scope-table /deep/ .el-button--text { |
|
|
|
padding: 0; |
|
|
|
line-height: 28px; |
|
|
|
} |
|
|
|
</style> |