|
|
@@ -18,9 +18,9 @@
|
|
|
>
|
|
|
<el-row>
|
|
|
<el-col :span="8">
|
|
|
- <el-form-item label="工单编号" prop="code">
|
|
|
+ <el-form-item label="工单编号" prop="orderCode">
|
|
|
<el-input
|
|
|
- v-model="addForm.code"
|
|
|
+ v-model="addForm.orderCode"
|
|
|
placeholder="自动带出"
|
|
|
disabled
|
|
|
></el-input>
|
|
|
@@ -32,22 +32,23 @@
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="8">
|
|
|
- <el-form-item label="执行部门" prop="groupId">
|
|
|
+ <el-form-item label="执行部门" prop="executeGroupId">
|
|
|
<deptSelect
|
|
|
- v-model="addForm.groupId"
|
|
|
- @change="searchDeptNodeClick"
|
|
|
+ v-model="addForm.executeGroupId"
|
|
|
+ @changeGroup="searchDeptNodeClick"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="8">
|
|
|
<el-form-item
|
|
|
label="执行人"
|
|
|
- prop="executorId"
|
|
|
+ prop="executeUserId"
|
|
|
:rules="[{ required: true, message: '请选择执行人' }]"
|
|
|
>
|
|
|
<personSelect
|
|
|
ref="executorRef"
|
|
|
- v-model="addForm.executorId"
|
|
|
+ v-model="addForm.executeUserId"
|
|
|
+ @selfChange="handleExecutorChange"
|
|
|
:init="false"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
@@ -130,61 +131,53 @@
|
|
|
<span>{{ scope.$index + 1 }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="备件名称" align="center" prop="name">
|
|
|
+ <el-table-column
|
|
|
+ label="备件名称"
|
|
|
+ align="center"
|
|
|
+ prop="categoryName"
|
|
|
+ >
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="规格型号" align="center" prop="modelType">
|
|
|
+ <el-table-column label="规格型号" align="center" prop="model">
|
|
|
<template slot-scope="{ row }">
|
|
|
- <span>{{ row.specification }}/{{ row.modelType }}</span>
|
|
|
+ <span>{{ row.specification }}/{{ row.model }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="所需数量" align="center" prop="num">
|
|
|
+ <el-table-column label="所需数量" align="center" prop="needNum">
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="单位" align="center" prop="measuringUnit">
|
|
|
+ <el-table-column label="单位" align="center" prop="unit">
|
|
|
</el-table-column>
|
|
|
<el-table-column label="费用" align="center" prop="univalence">
|
|
|
<template slot-scope="scope">
|
|
|
- {{ scope.row.num * scope.row.univalence
|
|
|
- }}{{ scope.row.univalenceUnit == 'wanyuan' ? '万元' : '元' }}
|
|
|
+ {{ scope.row.cost
|
|
|
+ }}{{ scope.row.parValue == 'wanyuan' ? '万元' : '元' }}
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
<div style="text-align: center"
|
|
|
>备件总费用:
|
|
|
- {{
|
|
|
- planDeviceList[currentEquItemIndex] &&
|
|
|
- planDeviceList[currentEquItemIndex].totalCost
|
|
|
- ? planDeviceList[currentEquItemIndex].totalCost
|
|
|
- : '-'
|
|
|
- }}
|
|
|
- 元
|
|
|
+ {{ totalCost || '-' }}
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div slot="footer" class="dialog_footer">
|
|
|
- <el-button type="primary" @click="submit">提交</el-button>
|
|
|
+ <el-button type="primary" @click="submit(false)">提交</el-button>
|
|
|
<el-button @click="handleClose">关闭</el-button>
|
|
|
+ <el-link type="primary" @click="submit(true)">提交并继续指派</el-link>
|
|
|
</div>
|
|
|
</el-dialog>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- import equipmentSelect from '@/components/CommomSelect/equipment-select.vue';
|
|
|
import personSelect from '@/components/CommomSelect/person-select.vue';
|
|
|
import deptSelect from '@/components/CommomSelect/dept-select.vue';
|
|
|
- import RuleItemSelection from '@/components/ruleItemSelection';
|
|
|
- import AddSpareDialog from '@/components/addSpareDialog';
|
|
|
+ import { getCode } from '@/api/ruleManagement/matter';
|
|
|
import {
|
|
|
- getRule,
|
|
|
- getCategory,
|
|
|
- getAssetList,
|
|
|
- getInfoById
|
|
|
- } from '@/api/ruleManagement/plan';
|
|
|
- import { getDetail, getCode } from '@/api/ruleManagement/matter';
|
|
|
- import { saveOrUpdate } from '@/api/maintenance/patrol_maintenance';
|
|
|
- import { deepClone } from '@/utils';
|
|
|
- import { getById } from '@/api/maintenance/patrol_maintenance';
|
|
|
+ getById,
|
|
|
+ getNotSendOrderList,
|
|
|
+ sendOrder
|
|
|
+ } from '@/api/maintenance/patrol_maintenance';
|
|
|
export default {
|
|
|
name: 'addPatrolPlanDialog',
|
|
|
components: {
|
|
|
@@ -219,24 +212,12 @@
|
|
|
4: 'INVENTORY'
|
|
|
},
|
|
|
addForm: {
|
|
|
- assetDict: '1',
|
|
|
- assetsName: '生产设备',
|
|
|
- // code: getRuleNo('PL'), // 计划单号
|
|
|
- cycleType: 0,
|
|
|
- name: '', // 计划名称
|
|
|
- autoOrder: 1, // 自动派单
|
|
|
- ruleId: '', // 规则id
|
|
|
- ruleName: '', // 规则名称
|
|
|
- duration: '', // 计划完成时长
|
|
|
- categoryLevelId: '', // 设备分类Id
|
|
|
- bizTypeName: '', // 设备分类name
|
|
|
- verifyUserId: '', // 审核人id
|
|
|
- verifyUserName: '', // 审核人name
|
|
|
- groupId: '', // 巡点检部门code
|
|
|
- executorId: '', // 巡点检人员id
|
|
|
- remark: '', // 备注
|
|
|
- categoryId: '', //
|
|
|
- planType: 'PATROL' // 计划规则类型 巡点检: 'PATROL', 保养: 'MAINTAIN', 盘点: 'INVENTORY'
|
|
|
+ executeGroupId: '',
|
|
|
+ executeGroupName: '',
|
|
|
+ executeUserId: '',
|
|
|
+ executeUserName: '',
|
|
|
+ orderCode: '',
|
|
|
+ name: ''
|
|
|
},
|
|
|
// 计划规则设备列表
|
|
|
planDeviceList: [
|
|
|
@@ -257,14 +238,14 @@
|
|
|
categoryLevelId: [
|
|
|
{ required: true, message: '请选择设备分类', trigger: 'change' }
|
|
|
],
|
|
|
- groupId: [
|
|
|
+ executeGroupId: [
|
|
|
{
|
|
|
required: true,
|
|
|
message: '请选择选择执行部门',
|
|
|
trigger: 'change'
|
|
|
}
|
|
|
],
|
|
|
- executorId: [
|
|
|
+ executeUserId: [
|
|
|
{
|
|
|
required: true,
|
|
|
message: '请选择选择执行人',
|
|
|
@@ -279,48 +260,61 @@
|
|
|
editLoading: false
|
|
|
};
|
|
|
},
|
|
|
- computed: {},
|
|
|
async created () {},
|
|
|
+ computed: {
|
|
|
+ totalCost () {
|
|
|
+ const cur = this.planDeviceList[this.currentEquItemIndex] || {};
|
|
|
+ const sparePart = cur?.sparePart || [];
|
|
|
+
|
|
|
+ return (
|
|
|
+ (sparePart.reduce((sum, item) => {
|
|
|
+ let chengs = 1;
|
|
|
+ switch (item.parValue) {
|
|
|
+ case 'wanyuan': {
|
|
|
+ chengs = 10000;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 'yuan': {
|
|
|
+ chengs = 1;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ console.log(sum, item.cost);
|
|
|
+ return sum + item.cost * chengs;
|
|
|
+ }, 0) || 0) + '元'
|
|
|
+ );
|
|
|
+ }
|
|
|
+ },
|
|
|
methods: {
|
|
|
open (row) {
|
|
|
- this.addForm.id = row.id;
|
|
|
- this.getInfo(this.addForm.id);
|
|
|
+ this.getInfo(row.id);
|
|
|
this.addPatrolPlanDialog = true;
|
|
|
},
|
|
|
// 编辑详情
|
|
|
- async getInfo (id) {
|
|
|
+ async getInfo (planId) {
|
|
|
this.editLoading = true;
|
|
|
- const res = await getById(id).catch(() => {
|
|
|
+ const res = await getById(planId).catch(() => {
|
|
|
this.editLoading = false;
|
|
|
});
|
|
|
this.editLoading = false;
|
|
|
if (res?.data) {
|
|
|
- const data = res.data;
|
|
|
-
|
|
|
- this.addForm = data;
|
|
|
-
|
|
|
- this.planDeviceList = this.addForm.planDeviceList.map((item) => ({
|
|
|
- ...item,
|
|
|
- ...item.substance
|
|
|
- }));
|
|
|
-
|
|
|
- const item = this.planDeviceList[0];
|
|
|
+ this.addForm = res.data;
|
|
|
+ this.getOrderCode();
|
|
|
+ this._getEquipmentList(res.data.planId);
|
|
|
+ }
|
|
|
+ },
|
|
|
|
|
|
- // const { equiLocation, equiLocationCode } = this.getEquiLocation(item);
|
|
|
- this.$nextTick(() => {
|
|
|
- this.$refs.equiListTree.setCurrentKey(item.id);
|
|
|
- this.equipmentInfo = {
|
|
|
- equiTypeId: this.addForm.categoryId,
|
|
|
- equiCode: item.code,
|
|
|
- equiName: item.name
|
|
|
- // equiModel: item.category.modelType
|
|
|
- // equiLocation: equiLocation,
|
|
|
- // equiLocationCode: equiLocationCode
|
|
|
- };
|
|
|
- this.currentEquItemIndex = 0;
|
|
|
- // this.planDeviceList[0]['equiLocation'] = equiLocation;
|
|
|
- // this.planDeviceList[0]['equiLocationCode'] = equiLocationCode;
|
|
|
- });
|
|
|
+ // 获取计划配置单号
|
|
|
+ async getOrderCode () {
|
|
|
+ if (this.type.includes('巡点检')) {
|
|
|
+ const data = await getCode('partrol_code');
|
|
|
+ this.$set(this.addForm, 'orderCode', data);
|
|
|
+ }
|
|
|
+ if (this.type.includes('保养')) {
|
|
|
+ const code = await getCode('maintenance_code');
|
|
|
+ this.$set(this.addForm, 'orderCode', code);
|
|
|
}
|
|
|
},
|
|
|
handleClose () {
|
|
|
@@ -352,69 +346,49 @@
|
|
|
equiLocationCode;
|
|
|
},
|
|
|
// 封装 - 获取设备分类列表
|
|
|
- async _getEquipmentList (val) {
|
|
|
- const params = {
|
|
|
- pageNum: 1,
|
|
|
- size: -1,
|
|
|
- categoryId: val || this.addForm.categoryId,
|
|
|
- rootCategoryLevelId: this.rootId
|
|
|
- };
|
|
|
- try {
|
|
|
- const res = await getAssetList(params);
|
|
|
- this.planDeviceList = res.list;
|
|
|
- this.planDeviceList.map((item) => {
|
|
|
- item.showName = item.name + '(' + item.code + ')';
|
|
|
- });
|
|
|
- this.currentEquItemIndex = 0;
|
|
|
- const item = this.planDeviceList[0];
|
|
|
- const { equiLocation, equiLocationCode } = this.getEquiLocation(item);
|
|
|
- this.$nextTick(() => {
|
|
|
- this.$refs.equiListTree.setCurrentKey(item.id);
|
|
|
- this.equipmentInfo = {
|
|
|
- equiTypeId: this.addForm.categoryId,
|
|
|
- equiCode: item.code,
|
|
|
- equiName: item.name,
|
|
|
- equiModel: item.category.modelType,
|
|
|
- equiLocation: equiLocation,
|
|
|
- equiLocationCode: equiLocationCode
|
|
|
- };
|
|
|
- this.currentEquItemIndex = 0;
|
|
|
- this.planDeviceList[0]['equiLocation'] = equiLocation;
|
|
|
- this.planDeviceList[0]['equiLocationCode'] = equiLocationCode;
|
|
|
-
|
|
|
- // 对比详情返回的数据和设备分类下面所有的设备列表,将sparePart同步过去
|
|
|
- if (this.addForm.planDeviceList) {
|
|
|
- for (let i = 0; i < this.planDeviceList.length; i++) {
|
|
|
- for (let j = 0; j < this.addForm.planDeviceList.length; j++) {
|
|
|
- if (
|
|
|
- this.planDeviceList[i].id ===
|
|
|
- this.addForm.planDeviceList[j].deviceId
|
|
|
- ) {
|
|
|
- this.$refs.equiListTree.setChecked(
|
|
|
- this.planDeviceList[i].id,
|
|
|
- true
|
|
|
- );
|
|
|
- this.planDeviceList[i]['workItems'] =
|
|
|
- this.addForm.planDeviceList[j]['workItems'];
|
|
|
- this.planDeviceList[i]['sparePart'] =
|
|
|
- this.addForm.planDeviceList[j]['sparePart'];
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- } catch (error) {
|
|
|
- this.planDeviceList = [];
|
|
|
+ async _getEquipmentList (planId) {
|
|
|
+ const data = await getNotSendOrderList(planId);
|
|
|
+ if (!data?.length) {
|
|
|
+ this.$message.error('所有设备已指派完!');
|
|
|
+ this.handleClose();
|
|
|
+ return;
|
|
|
}
|
|
|
+ this.planDeviceList = (data || []).map((item) => ({
|
|
|
+ showName: item.substance?.name + '(' + item.substance?.code + ')',
|
|
|
+ ...item,
|
|
|
+ ...item.substance,
|
|
|
+ id: item.id
|
|
|
+ }));
|
|
|
+ this.currentEquItemIndex = 0;
|
|
|
+ const item = this.planDeviceList[0];
|
|
|
+ const { equiLocation, equiLocationCode } = this.getEquiLocation(item);
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.equiListTree.setCurrentKey(item.id);
|
|
|
+ this.equipmentInfo = {
|
|
|
+ equiTypeId: this.addForm.categoryId,
|
|
|
+ equiCode: item.code,
|
|
|
+ equiName: item.name,
|
|
|
+ equiModel: item.model,
|
|
|
+ equiLocation: equiLocation,
|
|
|
+ equiLocationCode: equiLocationCode
|
|
|
+ };
|
|
|
+ this.planDeviceList[0]['equiLocation'] = equiLocation;
|
|
|
+ this.planDeviceList[0]['equiLocationCode'] = equiLocationCode;
|
|
|
+ });
|
|
|
},
|
|
|
//选择部门(搜索)
|
|
|
- searchDeptNodeClick (info) {
|
|
|
+ searchDeptNodeClick (id, info) {
|
|
|
+ this.addForm.executeGroupName = info?.name;
|
|
|
// 根据部门获取人员
|
|
|
- const params = { groupId: info };
|
|
|
+ const params = { executeGroupId: id };
|
|
|
this.$nextTick(() => {
|
|
|
this.$refs.executorRef.getList(params);
|
|
|
});
|
|
|
},
|
|
|
+ //执行人
|
|
|
+ handleExecutorChange (id, info) {
|
|
|
+ this.addForm.executeUserName = info?.name;
|
|
|
+ },
|
|
|
// 封装 - 获取设备位置名称和code方法
|
|
|
getEquiLocation (data) {
|
|
|
// 设备位置编码
|
|
|
@@ -424,61 +398,34 @@
|
|
|
return { equiLocation, equiLocationCode };
|
|
|
},
|
|
|
// 提交
|
|
|
- submit () {
|
|
|
- console.log(this.planDeviceList);
|
|
|
+ submit (isContinue = false) {
|
|
|
this.$refs.addFormRef.validate(async (valid) => {
|
|
|
if (valid) {
|
|
|
try {
|
|
|
- let workItemsChecked = true;
|
|
|
- const selectList = this.$refs.equiListTree.getCheckedNodes();
|
|
|
+ const selectList = this.$refs.equiListTree.getCheckedKeys();
|
|
|
if (!selectList.length) {
|
|
|
this.$message.warning('请选择设备!');
|
|
|
return;
|
|
|
}
|
|
|
- const planDeviceList = selectList.map((item) => {
|
|
|
- const obj = this.planDeviceList.find(
|
|
|
- (itm) => itm.id === item.id
|
|
|
- );
|
|
|
- if (!obj.workItems?.length) {
|
|
|
- workItemsChecked = false;
|
|
|
- }
|
|
|
-
|
|
|
- const { equiLocation, equiLocationCode } =
|
|
|
- this.getEquiLocation(item);
|
|
|
- return {
|
|
|
- equiCode: item.code,
|
|
|
- equiName: item.name,
|
|
|
- deviceId: item.id,
|
|
|
- equiModel: item.modelType,
|
|
|
- equiLocation: equiLocation,
|
|
|
- equiLocationCode: equiLocationCode,
|
|
|
- workItems: obj.workItems ? obj.workItems : [],
|
|
|
- sparePart: obj.sparePart ? obj.sparePart : []
|
|
|
- };
|
|
|
- });
|
|
|
-
|
|
|
- if (!workItemsChecked || !selectList.length) {
|
|
|
- this.$message.warning('请添加操作事项!');
|
|
|
- return;
|
|
|
- }
|
|
|
- if (this.addForm.planType instanceof Object) {
|
|
|
- this.addForm.planType =
|
|
|
- this.planRuleTypeObj[this.addForm.planType.code];
|
|
|
- }
|
|
|
|
|
|
// 将newData拼接成一个新数组赋值给后端接收字段
|
|
|
- const params = this.addForm;
|
|
|
- params.planDeviceList = planDeviceList;
|
|
|
+ const params = {
|
|
|
+ executeGroupId: this.addForm.executeGroupId,
|
|
|
+ executeGroupName: this.addForm.executeGroupName,
|
|
|
+ executeUserId: this.addForm.executeUserId,
|
|
|
+ executeUserName: this.addForm.executeUserName,
|
|
|
+ orderCode: this.addForm.orderCode,
|
|
|
+ planDeviceIds: selectList.join(','),
|
|
|
+ planId: this.addForm.planId
|
|
|
+ };
|
|
|
|
|
|
- params.type = this.dialogTitle.includes('巡点检')
|
|
|
- ? 1
|
|
|
- : this.dialogTitle.includes('保养')
|
|
|
- ? 2
|
|
|
- : 3;
|
|
|
- await saveOrUpdate(params);
|
|
|
- const type = this.dialogTitle.includes('新增') ? '新增' : '编辑';
|
|
|
- this.handleClose();
|
|
|
- this.$message.success(type + '成功!');
|
|
|
+ await sendOrder(params);
|
|
|
+ if (!isContinue) {
|
|
|
+ this.handleClose();
|
|
|
+ } else {
|
|
|
+ this._getEquipmentList(this.addForm.planId);
|
|
|
+ }
|
|
|
+ this.$message.success('派单成功!');
|
|
|
this.$emit('refreshList');
|
|
|
} catch (error) {
|
|
|
console.log(error);
|
|
|
@@ -492,9 +439,6 @@
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
::v-deep .el-form {
|
|
|
- .el-form-item {
|
|
|
- margin-bottom: 14px;
|
|
|
- }
|
|
|
.el-form-item__error {
|
|
|
padding-top: 0;
|
|
|
}
|
|
|
@@ -563,5 +507,11 @@
|
|
|
}
|
|
|
.dialog_footer {
|
|
|
text-align: center;
|
|
|
+ position: relative;
|
|
|
+ .el-link {
|
|
|
+ position: absolute;
|
|
|
+ right: 0;
|
|
|
+ top: 30%;
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|