|
@@ -92,25 +92,25 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { getInfo, getWorkType } from "@/api/crafts";
|
|
|
-import UploadComponent from "../common/upload-component";
|
|
|
-import WorkFlow from "@/components/work-flow-v2/home";
|
|
|
+import { getInfo, getWorkType } from '@/api/crafts'
|
|
|
+import UploadComponent from '../common/upload-component'
|
|
|
+import WorkFlow from '@/components/work-flow-v2/home'
|
|
|
// import data from "@/components/work-flow/config/data.json";
|
|
|
-import { GenNonDuplicateID } from "@/components/work-flow/until";
|
|
|
-import CraftProductComponent from "@/views/modules/common/craft-product-component";
|
|
|
-import { getOrderByCode } from "@/api/sale";
|
|
|
-import _ from "lodash";
|
|
|
+import { GenNonDuplicateID } from '@/components/work-flow/until'
|
|
|
+import CraftProductComponent from '@/views/modules/common/craft-product-component'
|
|
|
+import { getOrderByCode } from '@/api/sale'
|
|
|
+import _ from 'lodash'
|
|
|
export default {
|
|
|
- name: "add-or-update",
|
|
|
+ name: 'add-or-update',
|
|
|
components: { CraftProductComponent, UploadComponent, WorkFlow },
|
|
|
computed: {
|
|
|
orgId: {
|
|
|
- get() {
|
|
|
- return this.$store.state.user.orgId;
|
|
|
- },
|
|
|
- },
|
|
|
+ get () {
|
|
|
+ return this.$store.state.user.orgId
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
- data() {
|
|
|
+ data () {
|
|
|
return {
|
|
|
datas: {},
|
|
|
visible: false,
|
|
@@ -122,19 +122,19 @@ export default {
|
|
|
dataList: [],
|
|
|
id: 0,
|
|
|
dataForm: {
|
|
|
- techName: "",
|
|
|
- techVersion: "",
|
|
|
- productId: "",
|
|
|
- notes: "",
|
|
|
+ techName: '',
|
|
|
+ techVersion: '',
|
|
|
+ productId: '',
|
|
|
+ notes: ''
|
|
|
},
|
|
|
- previewPath: "",
|
|
|
- previewName: "",
|
|
|
+ previewPath: '',
|
|
|
+ previewName: '',
|
|
|
previewVisible: false,
|
|
|
optionsProducts: [],
|
|
|
optionLevel: [],
|
|
|
workFlowData: {
|
|
|
nodeList: [],
|
|
|
- lineList: [],
|
|
|
+ lineList: []
|
|
|
}, // 流程图数据
|
|
|
// 工艺流程表格数据
|
|
|
workFlowTableData: [],
|
|
@@ -144,210 +144,210 @@ export default {
|
|
|
orderOptions: [],
|
|
|
dataRule: {
|
|
|
techName: [
|
|
|
- { required: true, message: "工艺名称不能为空", trigger: "blur" },
|
|
|
+ { required: true, message: '工艺名称不能为空', trigger: 'blur' }
|
|
|
],
|
|
|
techVersion: [
|
|
|
- { required: true, message: "工艺版本不能为空", trigger: "blur" },
|
|
|
+ { required: true, message: '工艺版本不能为空', trigger: 'blur' }
|
|
|
],
|
|
|
productId: [
|
|
|
- { required: true, message: "物料不能为空", trigger: "change" },
|
|
|
- ],
|
|
|
+ { required: true, message: '物料不能为空', trigger: 'change' }
|
|
|
+ ]
|
|
|
},
|
|
|
dataRule1: {
|
|
|
name: [
|
|
|
- { required: true, message: "节点名称不能为空", trigger: "blur" },
|
|
|
+ { required: true, message: '节点名称不能为空', trigger: 'blur' }
|
|
|
],
|
|
|
type: [
|
|
|
- { required: true, message: "节点类型不能为空", trigger: "change" },
|
|
|
+ { required: true, message: '节点类型不能为空', trigger: 'change' }
|
|
|
],
|
|
|
workTypeId: [
|
|
|
- { required: true, message: "工种不能为空", trigger: "change" },
|
|
|
- ],
|
|
|
- },
|
|
|
- };
|
|
|
+ { required: true, message: '工种不能为空', trigger: 'change' }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
- created() {
|
|
|
- this.initNode();
|
|
|
+ created () {
|
|
|
+ this.initNode()
|
|
|
// 创建防抖函数(500ms延迟)
|
|
|
- this.debouncedSearch = _.debounce(this.remoteMethod, 500);
|
|
|
+ this.debouncedSearch = _.debounce(this.remoteMethod, 500)
|
|
|
},
|
|
|
- beforeDestroy() {
|
|
|
+ beforeDestroy () {
|
|
|
// 清除防抖定时器,避免内存泄漏
|
|
|
- this.debouncedSearch.cancel();
|
|
|
+ this.debouncedSearch.cancel()
|
|
|
},
|
|
|
- mounted() {
|
|
|
- this.initNode();
|
|
|
+ mounted () {
|
|
|
+ this.initNode()
|
|
|
},
|
|
|
methods: {
|
|
|
- onChose() {
|
|
|
- this.$emit("onChose");
|
|
|
+ onChose () {
|
|
|
+ this.$emit('onChose')
|
|
|
},
|
|
|
- initNode() {
|
|
|
+ initNode () {
|
|
|
// this.workFlowData = data;
|
|
|
},
|
|
|
- resetWorkFlow() {
|
|
|
+ resetWorkFlow () {
|
|
|
this.workFlowData = {
|
|
|
nodeList: [],
|
|
|
- lineList: [],
|
|
|
- };
|
|
|
+ lineList: []
|
|
|
+ }
|
|
|
},
|
|
|
- async init(id, display, isEdit, isCopy, isResubmit) {
|
|
|
- this.remoteMethod();
|
|
|
+ async init (id, display, isEdit, isCopy, isResubmit) {
|
|
|
+ this.remoteMethod()
|
|
|
|
|
|
- this.fileList = [];
|
|
|
+ this.fileList = []
|
|
|
this.dataForm = {
|
|
|
- techName: "",
|
|
|
- techVersion: "",
|
|
|
- productId: "",
|
|
|
- notes: "",
|
|
|
- };
|
|
|
- this.visible = true;
|
|
|
- this.display = display;
|
|
|
- this.isEdit = isEdit && !isCopy && !isResubmit;
|
|
|
- this.isCopy = isCopy || false;
|
|
|
- this.isResubmit = isResubmit || false;
|
|
|
+ techName: '',
|
|
|
+ techVersion: '',
|
|
|
+ productId: '',
|
|
|
+ notes: ''
|
|
|
+ }
|
|
|
+ this.visible = true
|
|
|
+ this.display = display
|
|
|
+ this.isEdit = isEdit && !isCopy && !isResubmit
|
|
|
+ this.isCopy = isCopy || false
|
|
|
+ this.isResubmit = isResubmit || false
|
|
|
|
|
|
// 获取车间工种列表
|
|
|
this.$http({
|
|
|
url: this.$http.adornUrl(`/biz-service/pro-workshop/list`),
|
|
|
- method: "get",
|
|
|
+ method: 'get',
|
|
|
params: this.$http.adornParams({
|
|
|
current: 1,
|
|
|
- size: 1000,
|
|
|
- }),
|
|
|
+ size: 1000
|
|
|
+ })
|
|
|
}).then(({ data }) => {
|
|
|
- if (data && data.code === "200") {
|
|
|
+ if (data && data.code === '200') {
|
|
|
// this.workTypeOptions = data.data.records;
|
|
|
- this.workTypeOptions = [];
|
|
|
+ this.workTypeOptions = []
|
|
|
|
|
|
for (var item of data.data.records) {
|
|
|
let first = {
|
|
|
name: item.name,
|
|
|
- children: [],
|
|
|
- };
|
|
|
+ children: []
|
|
|
+ }
|
|
|
|
|
|
if (item.proWorkTypeList != null) {
|
|
|
- first.children.push({ name: "结束", typeId: "", type: "end" });
|
|
|
+ first.children.push({ name: '结束', typeId: '', type: 'end' })
|
|
|
for (var subItem of item.proWorkTypeList) {
|
|
|
let second = {
|
|
|
name: subItem.name,
|
|
|
- typeId: subItem.typeId,
|
|
|
- };
|
|
|
+ typeId: subItem.typeId
|
|
|
+ }
|
|
|
|
|
|
- first.children.push(second);
|
|
|
+ first.children.push(second)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- this.workTypeOptions.push(first);
|
|
|
+ this.workTypeOptions.push(first)
|
|
|
}
|
|
|
|
|
|
- console.log("workTypeOptions:", this.workTypeOptions);
|
|
|
+ console.log('workTypeOptions:', this.workTypeOptions)
|
|
|
} else {
|
|
|
- this.$message.error(data.msg);
|
|
|
+ this.$message.error(data.msg)
|
|
|
}
|
|
|
- });
|
|
|
+ })
|
|
|
|
|
|
- if (!id) return;
|
|
|
+ if (!id) return
|
|
|
await getInfo(id).then(async ({ data }) => {
|
|
|
- if (data && data.code === "200") {
|
|
|
- this.dataForm = data.data;
|
|
|
+ if (data && data.code === '200') {
|
|
|
+ this.dataForm = data.data
|
|
|
// 附件
|
|
|
if (data.data.attachList) {
|
|
|
data.data.attachList.forEach((item) => {
|
|
|
this.fileList.push({
|
|
|
name: item.fileName,
|
|
|
url: item.url,
|
|
|
- id: item.url,
|
|
|
- });
|
|
|
- });
|
|
|
+ id: item.url
|
|
|
+ })
|
|
|
+ })
|
|
|
}
|
|
|
// 工艺流程
|
|
|
this.workFlowData = {
|
|
|
nodeList: data.data.nodeList,
|
|
|
- lineList: data.data.lineList,
|
|
|
- };
|
|
|
+ lineList: data.data.lineList
|
|
|
+ }
|
|
|
|
|
|
- console.log("workFlowData", this.workFlowData);
|
|
|
+ console.log('workFlowData', this.workFlowData)
|
|
|
}
|
|
|
- });
|
|
|
+ })
|
|
|
},
|
|
|
- productIdChangeHandle(val) {
|
|
|
+ productIdChangeHandle (val) {
|
|
|
if (val) {
|
|
|
- let item = this.optionLevel.find((t) => t.productId === val);
|
|
|
- this.dataForm.techName = item.productName;
|
|
|
+ let item = this.optionLevel.find((t) => t.productId === val)
|
|
|
+ this.dataForm.techName = item.productName
|
|
|
}
|
|
|
},
|
|
|
- handleRemove(file, fileList) {
|
|
|
- this.fileList = fileList;
|
|
|
+ handleRemove (file, fileList) {
|
|
|
+ this.fileList = fileList
|
|
|
},
|
|
|
- handleChange(file, fileList) {
|
|
|
- this.fileList = fileList;
|
|
|
+ handleChange (file, fileList) {
|
|
|
+ this.fileList = fileList
|
|
|
},
|
|
|
- handleExceed(files, fileList) {
|
|
|
+ handleExceed (files, fileList) {
|
|
|
this.$message.warning(
|
|
|
`当前限制选择 5 个文件,本次选择了 ${files.length} 个文件,共选择了 ${
|
|
|
files.length + fileList.length
|
|
|
} 个文件`
|
|
|
- );
|
|
|
+ )
|
|
|
},
|
|
|
- remoteMethod(query) {
|
|
|
- this.loading = true;
|
|
|
- this.getOrderByCode(query);
|
|
|
+ remoteMethod (query) {
|
|
|
+ this.loading = true
|
|
|
+ this.getOrderByCode(query)
|
|
|
},
|
|
|
- getOrderByCode(orderCode) {
|
|
|
+ getOrderByCode (orderCode) {
|
|
|
getOrderByCode(orderCode).then(({ data }) => {
|
|
|
- this.loading = false;
|
|
|
+ this.loading = false
|
|
|
|
|
|
- if (data && data.code === "200" && data.data) {
|
|
|
+ if (data && data.code === '200' && data.data) {
|
|
|
this.orderOptions = data.data.map((item) => {
|
|
|
- return { label: item.orderCode, value: item.orderId };
|
|
|
- });
|
|
|
+ return { label: item.orderCode, value: item.orderId }
|
|
|
+ })
|
|
|
}
|
|
|
- });
|
|
|
+ })
|
|
|
},
|
|
|
- validateField(type) {
|
|
|
- this.$refs.dataForm.validateField(type);
|
|
|
+ validateField (type) {
|
|
|
+ this.$refs.dataForm.validateField(type)
|
|
|
},
|
|
|
// 表单提交
|
|
|
- dataFormSubmit() {
|
|
|
- let flowData = this.$refs.workFlow.getFlowData();
|
|
|
+ dataFormSubmit () {
|
|
|
+ let flowData = this.$refs.workFlow.getFlowData()
|
|
|
if (!flowData) {
|
|
|
- this.$message.error("请先完成流程图!");
|
|
|
- return;
|
|
|
+ this.$message.error('请先完成流程图!')
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
- this.$refs["dataForm"].validate((valid) => {
|
|
|
+ this.$refs['dataForm'].validate((valid) => {
|
|
|
if (valid) {
|
|
|
// 填充附件
|
|
|
- let fList = this.fileList;
|
|
|
+ let fList = this.fileList
|
|
|
if (fList.length > 0) {
|
|
|
- this.dataForm.attachList = [];
|
|
|
+ this.dataForm.attachList = []
|
|
|
for (let i = 0; i < fList.length; i++) {
|
|
|
this.dataForm.attachList.push({
|
|
|
fileName: fList[i].name,
|
|
|
- url: fList[i].url,
|
|
|
- });
|
|
|
+ url: fList[i].url
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- let url = `/biz-service/technology/submit`;
|
|
|
+ let url = `/biz-service/technology/submit`
|
|
|
if (this.isResubmit) {
|
|
|
- url = `/biz-service/technology/resubmit`;
|
|
|
+ url = `/biz-service/technology/resubmit`
|
|
|
}
|
|
|
if (this.isEdit && !this.isCopy) {
|
|
|
- url = `/biz-service/technology/update`;
|
|
|
+ url = `/biz-service/technology/update`
|
|
|
}
|
|
|
|
|
|
if (this.isCopy) {
|
|
|
- this.dataForm.id = 0;
|
|
|
- this.dataForm.techId = null;
|
|
|
+ this.dataForm.id = 0
|
|
|
+ this.dataForm.techId = null
|
|
|
|
|
|
if (flowData.nodeList != null && flowData.nodeList.length > 0) {
|
|
|
for (let index = 0; index < flowData.nodeList.length; index++) {
|
|
|
- let oldId = flowData.nodeList[index].id;
|
|
|
- let newId = GenNonDuplicateID(8);
|
|
|
- flowData.nodeList[index].techId = null;
|
|
|
- flowData.nodeList[index].id = newId;
|
|
|
+ let oldId = flowData.nodeList[index].id
|
|
|
+ let newId = GenNonDuplicateID(8)
|
|
|
+ flowData.nodeList[index].techId = null
|
|
|
+ flowData.nodeList[index].id = newId
|
|
|
|
|
|
if (flowData.lineList != null && flowData.lineList.length > 0) {
|
|
|
for (
|
|
@@ -355,15 +355,15 @@ export default {
|
|
|
index < flowData.lineList.length;
|
|
|
index++
|
|
|
) {
|
|
|
- flowData.lineList[index].techId = null;
|
|
|
- flowData.lineList[index].id = GenNonDuplicateID(8);
|
|
|
- let from = flowData.lineList[index].from;
|
|
|
- let to = flowData.lineList[index].to;
|
|
|
+ flowData.lineList[index].techId = null
|
|
|
+ flowData.lineList[index].id = GenNonDuplicateID(8)
|
|
|
+ let from = flowData.lineList[index].from
|
|
|
+ let to = flowData.lineList[index].to
|
|
|
if (from === oldId) {
|
|
|
- flowData.lineList[index].from = newId;
|
|
|
+ flowData.lineList[index].from = newId
|
|
|
}
|
|
|
if (to === oldId) {
|
|
|
- flowData.lineList[index].to = newId;
|
|
|
+ flowData.lineList[index].to = newId
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -373,58 +373,58 @@ export default {
|
|
|
|
|
|
this.$http({
|
|
|
url: this.$http.adornUrl(url),
|
|
|
- method: "post",
|
|
|
+ method: 'post',
|
|
|
data: this.$http.adornData({
|
|
|
...this.dataForm,
|
|
|
- ...flowData,
|
|
|
- }),
|
|
|
+ ...flowData
|
|
|
+ })
|
|
|
}).then(({ data }) => {
|
|
|
- if (data && data.code === "200") {
|
|
|
+ if (data && data.code === '200') {
|
|
|
this.$message({
|
|
|
- message: "操作成功",
|
|
|
- type: "success",
|
|
|
+ message: '操作成功',
|
|
|
+ type: 'success',
|
|
|
duration: 1500,
|
|
|
onClose: () => {
|
|
|
- this.resetWorkFlow();
|
|
|
- this.onChose();
|
|
|
- this.$emit("refreshDataList");
|
|
|
- },
|
|
|
- });
|
|
|
+ this.resetWorkFlow()
|
|
|
+ this.onChose()
|
|
|
+ this.$emit('refreshDataList')
|
|
|
+ }
|
|
|
+ })
|
|
|
} else {
|
|
|
- this.$message.error(data.msg);
|
|
|
+ this.$message.error(data.msg)
|
|
|
}
|
|
|
- });
|
|
|
+ })
|
|
|
}
|
|
|
- });
|
|
|
+ })
|
|
|
},
|
|
|
- uploadSuccess(fileList) {
|
|
|
- this.fileList = fileList;
|
|
|
+ uploadSuccess (fileList) {
|
|
|
+ this.fileList = fileList
|
|
|
},
|
|
|
// 保存流程图
|
|
|
- saveWorkFlow(workFlowData) {
|
|
|
- console.log("save work flow.");
|
|
|
- this.workFlowData = workFlowData;
|
|
|
+ saveWorkFlow (workFlowData) {
|
|
|
+ console.log('save work flow.')
|
|
|
+ this.workFlowData = workFlowData
|
|
|
},
|
|
|
// 流程图数据变更通知
|
|
|
- workFlowDataChange() {},
|
|
|
- handleClose() {
|
|
|
+ workFlowDataChange () {},
|
|
|
+ handleClose () {
|
|
|
// this.visible = false
|
|
|
- this.$emit("close");
|
|
|
+ this.$emit('close')
|
|
|
},
|
|
|
- async getWorkTypeOptions() {
|
|
|
- this.workTypeOptions = [];
|
|
|
+ async getWorkTypeOptions () {
|
|
|
+ this.workTypeOptions = []
|
|
|
await getWorkType().then(({ data }) => {
|
|
|
- if (data && data.code === "200") {
|
|
|
- this.workTypeOptions = data.data;
|
|
|
+ if (data && data.code === '200') {
|
|
|
+ this.workTypeOptions = data.data
|
|
|
// console.log(data.data)
|
|
|
}
|
|
|
- });
|
|
|
+ })
|
|
|
},
|
|
|
- prodSelected(item) {
|
|
|
- this.dataForm.productId = item.value;
|
|
|
- },
|
|
|
- },
|
|
|
-};
|
|
|
+ prodSelected (item) {
|
|
|
+ this.dataForm.productId = item.value
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style lang="less" scoped>
|