|
|
@@ -74,7 +74,7 @@
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
- <el-col :span="8">
|
|
|
+ <!-- <el-col :span="8">
|
|
|
<el-form-item label="设备类别" prop="categoryId">
|
|
|
<el-select
|
|
|
v-model="addForm.categoryId"
|
|
|
@@ -90,7 +90,7 @@
|
|
|
></el-option>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
- </el-col>
|
|
|
+ </el-col> -->
|
|
|
<el-col :span="8">
|
|
|
<el-form-item label="审核人" prop="verifyUserId">
|
|
|
<personSelect v-model="addForm.verifyUserId" />
|
|
|
@@ -305,6 +305,7 @@
|
|
|
import { saveOrUpdate } from '@/api/maintenance/patrol_maintenance';
|
|
|
import { deepClone } from '@/utils';
|
|
|
import { getById } from '@/api/maintenance/patrol_maintenance';
|
|
|
+ import { getList } from '@/api/classifyManage/itemInformation';
|
|
|
export default {
|
|
|
name: 'addPatrolPlanDialog',
|
|
|
components: {
|
|
|
@@ -316,7 +317,7 @@
|
|
|
AddSpareDialog
|
|
|
},
|
|
|
props: {},
|
|
|
- data () {
|
|
|
+ data() {
|
|
|
return {
|
|
|
defaultProps: {
|
|
|
label: 'showName'
|
|
|
@@ -398,13 +399,14 @@
|
|
|
currentNode: null,
|
|
|
rootId: null,
|
|
|
dialogTitle: '新增保养计划配置',
|
|
|
- editLoading: false
|
|
|
+ editLoading: false,
|
|
|
+ rootData: []
|
|
|
};
|
|
|
},
|
|
|
computed: {},
|
|
|
- async created () {},
|
|
|
+ async created() {},
|
|
|
methods: {
|
|
|
- open (title, row) {
|
|
|
+ open(title, row) {
|
|
|
this.dialogTitle = title;
|
|
|
this.formLabel = this.dialogTitle.includes('巡点检')
|
|
|
? '巡点检'
|
|
|
@@ -431,14 +433,16 @@
|
|
|
this.addPatrolPlanDialog = true;
|
|
|
},
|
|
|
// 编辑详情
|
|
|
- async getInfo (id) {
|
|
|
+ async getInfo(id) {
|
|
|
this.editLoading = true;
|
|
|
- const res = await getById(id).catch(() => {
|
|
|
+ const res = await getById(id).finally(() => {
|
|
|
this.editLoading = false;
|
|
|
});
|
|
|
if (res?.data) {
|
|
|
- const data = res.data;
|
|
|
-
|
|
|
+ let data = res.data;
|
|
|
+ if (data.executor && data.executor.length) {
|
|
|
+ data.groupId = data.executor[0].groupName;
|
|
|
+ }
|
|
|
this.addForm = data;
|
|
|
|
|
|
this.categoryEquipment(this.addForm.categoryLevelId);
|
|
|
@@ -454,7 +458,7 @@
|
|
|
}
|
|
|
},
|
|
|
// 获取计划配置单号
|
|
|
- async getOrderCode (tips) {
|
|
|
+ async getOrderCode(tips) {
|
|
|
if (tips.includes('巡点检')) {
|
|
|
const data = await getCode('partrol_code');
|
|
|
this.$set(this.addForm, 'code', data);
|
|
|
@@ -465,19 +469,22 @@
|
|
|
}
|
|
|
},
|
|
|
// 获取规则名列表
|
|
|
- async _getRuleNameList () {
|
|
|
+ async _getRuleNameList() {
|
|
|
if (this.dialogTitle == '新增巡点检计划') {
|
|
|
console.log('巡点检计划');
|
|
|
const res = await getRule({ type: 1, pageNum: 1, size: -1 });
|
|
|
this.ruleNameList = res.list || [];
|
|
|
}
|
|
|
- if (this.dialogTitle == '新增保养计划') {
|
|
|
+ if (
|
|
|
+ this.dialogTitle == '新增保养计划' ||
|
|
|
+ this.dialogTitle == '编辑保养计划'
|
|
|
+ ) {
|
|
|
console.log('保养计划');
|
|
|
const res = await getRule({ type: 2, pageNum: 1, size: -1 });
|
|
|
this.ruleNameList = res.list || [];
|
|
|
}
|
|
|
},
|
|
|
- handleClose () {
|
|
|
+ handleClose() {
|
|
|
this.addPatrolPlanDialog = false;
|
|
|
this.$refs.addFormRef.resetFields();
|
|
|
if (this.$refs.searchTree) {
|
|
|
@@ -504,36 +511,83 @@
|
|
|
planType: 'PATROL' // 计划规则类型 巡点检: 'PATROL', 保养: 'MAINTAIN', 盘点: 'INVENTORY'
|
|
|
};
|
|
|
},
|
|
|
- getRootId (val) {
|
|
|
- this.rootId = val;
|
|
|
+ getRootId(val, data) {
|
|
|
+ // this.rootId = val;
|
|
|
+ this.rootData = data;
|
|
|
},
|
|
|
// 设备分类选择
|
|
|
- async handleEquipmentClassChange (item) {
|
|
|
+ async handleEquipmentClassChange(item) {
|
|
|
this.clickedTreeNode = true;
|
|
|
this.equipmentInfo = {};
|
|
|
this._getEquipmentList(item.id);
|
|
|
},
|
|
|
|
|
|
// 获取设备分类数据
|
|
|
- async categoryEquipment (id) {
|
|
|
- const params = { categoryLevelId: id, pageNum: 1, size: -1 };
|
|
|
- const data = await getCategory(params);
|
|
|
+ async categoryEquipment(id) {
|
|
|
+ const params = {
|
|
|
+ searchKey: '',
|
|
|
+ categoryLevelId: id,
|
|
|
+ pageNum: 1,
|
|
|
+ size: 99
|
|
|
+ };
|
|
|
+ const data = await getList(params);
|
|
|
this.equipmentList = data.list;
|
|
|
},
|
|
|
// 分类树的选择
|
|
|
- chooseClassify (val) {
|
|
|
- this.categoryEquipment(val);
|
|
|
+ chooseClassify(val) {
|
|
|
+ this.clickedTreeNode = true;
|
|
|
+ const id = this.findTopLevelAncestorId(this.rootData, val);
|
|
|
+ this.rootId = id;
|
|
|
+ this._getEquipmentList(val, this.isBindPlan);
|
|
|
+ // this.categoryEquipment(val);
|
|
|
+ },
|
|
|
+ findTopLevelAncestorId(dataArray, targetId) {
|
|
|
+ for (const item of dataArray) {
|
|
|
+ const result = this.findTopLevelAncestorIdRecursive(
|
|
|
+ item,
|
|
|
+ targetId,
|
|
|
+ item.id
|
|
|
+ );
|
|
|
+ if (result) {
|
|
|
+ return result; // 返回找到的最顶层祖先的 ID
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ },
|
|
|
+
|
|
|
+ findTopLevelAncestorIdRecursive(dataItem, targetId, topLevelAncestorId) {
|
|
|
+ if (dataItem.id === targetId) {
|
|
|
+ return topLevelAncestorId;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (dataItem.children) {
|
|
|
+ for (const child of dataItem.children) {
|
|
|
+ const result = this.findTopLevelAncestorIdRecursive(
|
|
|
+ child,
|
|
|
+ targetId,
|
|
|
+ topLevelAncestorId
|
|
|
+ );
|
|
|
+ if (result) {
|
|
|
+ return result; // 返回找到的最顶层祖先的 ID
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
},
|
|
|
// 封装 - 获取设备分类列表
|
|
|
- async _getEquipmentList (val) {
|
|
|
+ async _getEquipmentList(val) {
|
|
|
const params = {
|
|
|
pageNum: 1,
|
|
|
- size: -1,
|
|
|
- categoryId: val || this.addForm.categoryId,
|
|
|
- rootCategoryLevelId: this.rootId
|
|
|
+ size: 999,
|
|
|
+ categoryLevelId: val || this.addForm.categoryId,
|
|
|
+ rootCategoryLevelId: this.rootId ? this.rootId : ''
|
|
|
};
|
|
|
try {
|
|
|
+ console.log('1', params);
|
|
|
const res = await getAssetList(params);
|
|
|
+ this.addForm.categoryId = res.list[0]?.categoryId;
|
|
|
this.planDeviceList = res.list;
|
|
|
this.planDeviceList.map((item) => {
|
|
|
item.showName = item.name + '(' + item.code + ')';
|
|
|
@@ -588,7 +642,7 @@
|
|
|
}
|
|
|
},
|
|
|
//选择部门(搜索)
|
|
|
- searchDeptNodeClick (info) {
|
|
|
+ searchDeptNodeClick(info) {
|
|
|
// 根据部门获取人员
|
|
|
const params = { groupId: info };
|
|
|
this.$nextTick(() => {
|
|
|
@@ -596,7 +650,7 @@
|
|
|
});
|
|
|
},
|
|
|
// 封装 - 获取设备位置名称和code方法
|
|
|
- getEquiLocation (data) {
|
|
|
+ getEquiLocation(data) {
|
|
|
// 设备位置编码
|
|
|
const equiLocationCode = data.position[0].pathIds;
|
|
|
// 设备位置名称
|
|
|
@@ -604,7 +658,7 @@
|
|
|
return { equiLocation, equiLocationCode };
|
|
|
},
|
|
|
// 设备列表树点击
|
|
|
- handleNodeClick (data, node) {
|
|
|
+ handleNodeClick(data, node) {
|
|
|
const { equiLocation, equiLocationCode } = this.getEquiLocation(data);
|
|
|
this.equipmentInfo = {
|
|
|
equiCode: data.code,
|
|
|
@@ -625,13 +679,13 @@
|
|
|
equiLocationCode;
|
|
|
},
|
|
|
// 规则名称下拉触发
|
|
|
- handleRuleNameChange (val) {
|
|
|
+ handleRuleNameChange(val) {
|
|
|
// this._getMatterRulesDetails(val);
|
|
|
this.$refs.ruleItemSelectionRef._getMatterRulesDetails(val);
|
|
|
},
|
|
|
|
|
|
// 从事项弹窗将数据丢到事项配置
|
|
|
- ruleItemSelectionSubmit (list) {
|
|
|
+ ruleItemSelectionSubmit(list) {
|
|
|
if (list) {
|
|
|
if (!this.planDeviceList[this.currentEquItemIndex]['workItems']) {
|
|
|
this.planDeviceList[this.currentEquItemIndex]['workItems'] = [];
|
|
|
@@ -651,7 +705,8 @@
|
|
|
},
|
|
|
|
|
|
// 添加操作事项
|
|
|
- addOperationItems () {
|
|
|
+ addOperationItems() {
|
|
|
+ console.log(this.clickedTreeNode);
|
|
|
if (!this.clickedTreeNode) {
|
|
|
return this.$message.warning('请选择设备分类!');
|
|
|
}
|
|
|
@@ -668,7 +723,7 @@
|
|
|
},
|
|
|
|
|
|
// 删除操作事项
|
|
|
- handleDeleteOperationItem (index) {
|
|
|
+ handleDeleteOperationItem(index) {
|
|
|
if (this.planDeviceList[this.currentEquItemIndex]['workItems']) {
|
|
|
this.planDeviceList[this.currentEquItemIndex]['workItems'].splice(
|
|
|
index,
|
|
|
@@ -678,7 +733,7 @@
|
|
|
},
|
|
|
|
|
|
// 添加备品备件
|
|
|
- addSpareItems () {
|
|
|
+ addSpareItems() {
|
|
|
if (!this.clickedTreeNode) {
|
|
|
return this.$message.warning('请选择设备分类!');
|
|
|
}
|
|
|
@@ -698,7 +753,7 @@
|
|
|
},
|
|
|
|
|
|
// 从备品备件弹窗将数据丢到备品备件配置
|
|
|
- spareItemSelectSubmit (list) {
|
|
|
+ spareItemSelectSubmit(list) {
|
|
|
// console.log('备品备件:', list)
|
|
|
// this.planDeviceList[this.currentEquItemIndex]['sparePart'] =
|
|
|
// list.map(item => {
|
|
|
@@ -719,7 +774,7 @@
|
|
|
},
|
|
|
|
|
|
// 删除备品备件
|
|
|
- handleDeleteSpareItem (index) {
|
|
|
+ handleDeleteSpareItem(index) {
|
|
|
this.planDeviceList[this.currentEquItemIndex]['sparePart'].splice(
|
|
|
index,
|
|
|
1
|
|
|
@@ -728,7 +783,7 @@
|
|
|
},
|
|
|
|
|
|
// 改变input数据重新计算总费用
|
|
|
- changeNum () {
|
|
|
+ changeNum() {
|
|
|
let applayList =
|
|
|
this.planDeviceList[this.currentEquItemIndex].sparePart;
|
|
|
let total = 0;
|
|
|
@@ -764,8 +819,19 @@
|
|
|
);
|
|
|
},
|
|
|
// 提交
|
|
|
- submit () {
|
|
|
+ submit() {
|
|
|
console.log(this.planDeviceList);
|
|
|
+ this.planDeviceList.forEach((item) => {
|
|
|
+ // 判断是否存在 workItems 属性,如果不存在则添加一个空数组
|
|
|
+ if (!item.workItems) {
|
|
|
+ item.workItems = [];
|
|
|
+ }
|
|
|
+
|
|
|
+ // 判断 workItems 是否为空数组,如果为空则添加有数据的 workItems
|
|
|
+ if (item.workItems.length === 0) {
|
|
|
+ item.workItems.push(/* 添加有数据的 workItems,可以根据需求添加具体的数据 */);
|
|
|
+ }
|
|
|
+ });
|
|
|
this.$refs.addFormRef.validate(async (valid) => {
|
|
|
if (valid) {
|
|
|
try {
|
|
|
@@ -779,7 +845,9 @@
|
|
|
const obj = this.planDeviceList.find(
|
|
|
(itm) => itm.id === item.id
|
|
|
);
|
|
|
+ console.log('obj.workItems:', obj);
|
|
|
if (!obj.workItems?.length) {
|
|
|
+ console.log(111);
|
|
|
workItemsChecked = false;
|
|
|
}
|
|
|
|
|
|
@@ -796,7 +864,6 @@
|
|
|
sparePart: obj.sparePart ? obj.sparePart : []
|
|
|
};
|
|
|
});
|
|
|
-
|
|
|
if (!workItemsChecked || !selectList.length) {
|
|
|
this.$message.warning('请添加操作事项!');
|
|
|
return;
|