|
|
@@ -31,6 +31,7 @@
|
|
|
<ItemForm
|
|
|
ref="itemFormRef"
|
|
|
:itemForm="itemForm"
|
|
|
+ :prefix="prefix"
|
|
|
:defaultNum="defaultNum"
|
|
|
/>
|
|
|
</div>
|
|
|
@@ -68,9 +69,9 @@
|
|
|
import {
|
|
|
informationAdd,
|
|
|
getDetails,
|
|
|
- informationEdit,
|
|
|
- getOrderNo
|
|
|
+ informationEdit
|
|
|
} from '@/api/classifyManage/itemInformation';
|
|
|
+ import { getCode } from '@/api/codeManagement';
|
|
|
export default {
|
|
|
components: { ItemForm, RowForm, ItemMatch },
|
|
|
mixins: [dictMixins],
|
|
|
@@ -78,11 +79,12 @@
|
|
|
return {
|
|
|
pageTitle: '',
|
|
|
itemForm: {
|
|
|
- classificationUrlId: [],
|
|
|
+ categoryLevelPathId: [],
|
|
|
addList: [],
|
|
|
info: {
|
|
|
angle: 'notA'
|
|
|
},
|
|
|
+ unpack: 0,
|
|
|
urlIdList: [],
|
|
|
univalenceUnit: 'yuan',
|
|
|
expirationDateUnit: 'minute',
|
|
|
@@ -99,6 +101,13 @@
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
+ prefix () {
|
|
|
+ const obj =
|
|
|
+ (this.dict[this.dictEnum['分类编号']] || []).find(
|
|
|
+ (itm) => itm.dictCode === this.defaultNum
|
|
|
+ ) || {};
|
|
|
+ return obj && obj.dictValue;
|
|
|
+ },
|
|
|
typeList () {
|
|
|
const noList = this.dict[this.dictEnum['分类编号']] || [];
|
|
|
|
|
|
@@ -115,22 +124,20 @@
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
- created () {
|
|
|
- this.requestDict('分类编号');
|
|
|
- this.requestDict('类型用途');
|
|
|
+ async created () {
|
|
|
+ await this.requestDict('分类编号');
|
|
|
+ await this.requestDict('类型用途');
|
|
|
this.pageTitle = this.$route.query.pageTitle;
|
|
|
if (this.pageTitle == '新建物品') {
|
|
|
this.selectNode = JSON.parse(this.$route.query.selectNode);
|
|
|
console.log('selectNode', this.selectNode);
|
|
|
if (this.selectNode) {
|
|
|
- this.itemForm.classificationId = this.selectNode.id;
|
|
|
- let code = 1;
|
|
|
+ this.itemForm.categoryLevelPathId = this.selectNode.id;
|
|
|
if (this.selectNode.id != '0') {
|
|
|
this.defaultNum = this.selectNode.type;
|
|
|
this.setDefault(this.defaultNum);
|
|
|
}
|
|
|
this.itemForm.urlIdList = this.selectNode.urlIdList;
|
|
|
- this.getTreeData(code);
|
|
|
}
|
|
|
} else {
|
|
|
this.getDetilInfo(this.$route.query.id);
|
|
|
@@ -144,12 +151,9 @@
|
|
|
},
|
|
|
methods: {
|
|
|
async getOrderCode () {
|
|
|
- const res = await getOrderNo(this.defaultNum);
|
|
|
- if (res.success) {
|
|
|
- this.newCode = res.data;
|
|
|
- this.$set(this.itemForm, 'itemCode', res.data.substring(3));
|
|
|
- // console.log('itemCode',res.data)
|
|
|
- }
|
|
|
+ const data = await getCode('material_management');
|
|
|
+ this.newCode = data;
|
|
|
+ this.$set(this.itemForm, 'itemCode', data);
|
|
|
},
|
|
|
|
|
|
// 在 Input 值改变时触发
|
|
|
@@ -163,51 +167,44 @@
|
|
|
|
|
|
// 获取详情
|
|
|
async getDetilInfo (id) {
|
|
|
- const res = await getDetails(id);
|
|
|
- if (res.success) {
|
|
|
- this.defaultNum = res.data.classificationCode;
|
|
|
- this.chooseItem(res.data.classificationCode);
|
|
|
- this.itemForm = res.data;
|
|
|
- if (res.data.univalence) {
|
|
|
- this.$set(this.itemForm, 'univalence', res.data.univalence);
|
|
|
- } else {
|
|
|
- this.$set(this.itemForm, 'univalence', 'null');
|
|
|
- }
|
|
|
- if (res.data.expirationDate) {
|
|
|
- this.$set(this.itemForm, 'expirationDate', res.data.expirationDate);
|
|
|
- } else {
|
|
|
- this.$set(this.itemForm, 'expirationDate', 'null');
|
|
|
- }
|
|
|
- this.$set(this.itemForm, 'info', JSON.parse(res.data.extendField));
|
|
|
- this.$set(this.itemForm, 'informationName', res.data.informationName);
|
|
|
- this.$set(
|
|
|
- this.itemForm,
|
|
|
- 'addList',
|
|
|
- JSON.parse(res.data.selfDefinedParameter)
|
|
|
- );
|
|
|
- this.itemForm.urlIdList = JSON.parse(res.data.classificationUrlId);
|
|
|
- if (this.pageTitle == '编辑物品') {
|
|
|
- // this.itemForm.itemCode = res.data.informationCode.substring(3)
|
|
|
- this.$set(
|
|
|
- this.itemForm,
|
|
|
- 'itemCode',
|
|
|
- res.data.informationCode.substring(3)
|
|
|
+ const data = await getDetails(id);
|
|
|
+ this.chooseItem({ code: data.type });
|
|
|
+ this.itemForm = data;
|
|
|
+ if (data.univalence) {
|
|
|
+ this.$set(this.itemForm, 'univalence', data.univalence);
|
|
|
+ } else {
|
|
|
+ this.$set(this.itemForm, 'univalence', 'null');
|
|
|
+ }
|
|
|
+ if (data.expirationDate) {
|
|
|
+ this.$set(this.itemForm, 'expirationDate', data.expirationDate);
|
|
|
+ } else {
|
|
|
+ this.$set(this.itemForm, 'expirationDate', 'null');
|
|
|
+ }
|
|
|
+ this.$set(this.itemForm, 'info', JSON.parse(data.extendField));
|
|
|
+ this.$set(this.itemForm, 'name', data.name);
|
|
|
+ this.$set(
|
|
|
+ this.itemForm,
|
|
|
+ 'addList',
|
|
|
+ JSON.parse(data.selfDefinedParameter)
|
|
|
+ );
|
|
|
+ this.itemForm.urlIdList = JSON.parse(data.categoryLevelPathId);
|
|
|
+ if (this.pageTitle == '编辑物品') {
|
|
|
+ // this.itemForm.itemCode = data.code.substring(3)
|
|
|
+ this.$set(this.itemForm, 'itemCode', data.code.substring(3));
|
|
|
+ } else {
|
|
|
+ this.$set(this.itemForm, 'isCitation', false);
|
|
|
+ this.$set(this.itemForm, 'itemCode', this.newCode.substring(3));
|
|
|
+ }
|
|
|
+ this.$set(this.itemForm, 'unpack', data.unpack);
|
|
|
+ // this.itemForm.isTransferAssets = data.isTransferAssets
|
|
|
+ // ? 'true'
|
|
|
+ // : 'false';
|
|
|
+ for (const key in this.itemForm.categoryVoRelationMap) {
|
|
|
+ this.$refs.itemMatchRef &&
|
|
|
+ this.$refs.itemMatchRef.matchList(
|
|
|
+ key,
|
|
|
+ this.itemForm.categoryVoRelationMap
|
|
|
);
|
|
|
- } else {
|
|
|
- this.$set(this.itemForm, 'isCitation', false);
|
|
|
- this.$set(this.itemForm, 'itemCode', this.newCode.substring(3));
|
|
|
- }
|
|
|
- this.itemForm.isTransferAssets = res.data.isTransferAssets
|
|
|
- ? 'true'
|
|
|
- : 'false';
|
|
|
- this.itemForm.isUnpack = res.data.isUnpack ? 'true' : 'false';
|
|
|
- for (const key in this.itemForm.informationRelationMap) {
|
|
|
- this.$refs.itemMatchRef &&
|
|
|
- this.$refs.itemMatchRef.matchList(
|
|
|
- key,
|
|
|
- this.itemForm.informationRelationMap
|
|
|
- );
|
|
|
- }
|
|
|
}
|
|
|
},
|
|
|
|
|
|
@@ -217,9 +214,8 @@
|
|
|
this.initItemForm();
|
|
|
this.$refs.itemFormRef.$refs.formName.resetFields();
|
|
|
this.getOrderCode();
|
|
|
- this.itemForm.classificationCode = item.prefix;
|
|
|
+ this.itemForm.type = item.code;
|
|
|
this.selectNode = null;
|
|
|
- this.getTreeData(item.code);
|
|
|
this.setDefault(item.code);
|
|
|
},
|
|
|
|
|
|
@@ -239,20 +235,16 @@
|
|
|
|
|
|
this.requestData = this.itemForm;
|
|
|
const { pathName, pathId } = this.$refs.itemFormRef.getText();
|
|
|
- this.requestData.classificationUrl = pathName;
|
|
|
- this.requestData.classificationId = pathId;
|
|
|
- this.requestData.isTransferAssets =
|
|
|
- this.requestData.isTransferAssets == 'true' ? true : false;
|
|
|
- this.requestData.isUnpack =
|
|
|
- this.requestData.isUnpack == 'true' ? true : false;
|
|
|
+ this.requestData.categoryLevelPath = pathName;
|
|
|
+ this.requestData.categoryLevelId = pathId;
|
|
|
+ this.requestData.type = this.defaultNum;
|
|
|
this.requestData.selfDefinedParameter = JSON.stringify(
|
|
|
this.requestData.addList
|
|
|
);
|
|
|
this.requestData.extendField = JSON.stringify(this.requestData.info);
|
|
|
- this.requestData.informationCode =
|
|
|
- this.defaultNum + this.requestData.itemCode;
|
|
|
+ this.requestData.code = this.prefix + this.requestData.itemCode;
|
|
|
this.requestData.classificationCode = this.defaultNum;
|
|
|
- this.requestData.classificationUrlId = JSON.stringify(
|
|
|
+ this.requestData.categoryLevelPathId = JSON.stringify(
|
|
|
this.requestData.urlIdList
|
|
|
);
|
|
|
this.requestData.expirationDate = this.itemForm.expirationDate
|
|
|
@@ -261,13 +253,15 @@
|
|
|
this.requestData.univalence = this.itemForm.univalence
|
|
|
? this.itemForm.univalence
|
|
|
: null;
|
|
|
- this.requestData.informationRelation =
|
|
|
+ this.requestData.categoryVoRelation =
|
|
|
(this.$refs.itemMatchRef && this.$refs.itemMatchRef.getMapList()) ||
|
|
|
[];
|
|
|
|
|
|
+ //不传报错
|
|
|
+ this.requestData.iotProductSchema = '{}';
|
|
|
if (this.pageTitle == '编辑物品') {
|
|
|
this.requestData.mainInformationId = this.$route.query.id;
|
|
|
- delete this.requestData.informationRelationMap;
|
|
|
+ delete this.requestData.categoryVoRelationMap;
|
|
|
this.$confirm(
|
|
|
'参数信息有变更,与当前已存在的台账信息参数不一致,确定后将同步已存在的台账信息参数 !',
|
|
|
'重要提示!',
|
|
|
@@ -280,52 +274,24 @@
|
|
|
)
|
|
|
.then(() => {
|
|
|
informationEdit(this.requestData).then((res) => {
|
|
|
- if (res.success) {
|
|
|
- this.$message.success('物品编辑成功');
|
|
|
- this.$router.push({
|
|
|
- path: '/warehouseManagement/itemInformation'
|
|
|
- });
|
|
|
- }
|
|
|
+ this.$message.success('物品编辑成功');
|
|
|
+ this.$router.push({
|
|
|
+ path: '/classifyManage/itemInformation'
|
|
|
+ });
|
|
|
});
|
|
|
})
|
|
|
.catch(() => {});
|
|
|
} else {
|
|
|
informationAdd(this.requestData).then((res) => {
|
|
|
- if (res.success) {
|
|
|
- this.$message.success('物品新增成功');
|
|
|
- this.$router.push({
|
|
|
- path: '/warehouseManagement/itemInformation'
|
|
|
- });
|
|
|
- }
|
|
|
+ this.$message.success('物品新增成功');
|
|
|
+ this.$router.push({
|
|
|
+ path: '/classifyManage/itemInformation'
|
|
|
+ });
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
|
|
|
- async getTreeData (code) {
|
|
|
- // try {
|
|
|
- // const res = await common.getClassify({
|
|
|
- // type: code,
|
|
|
- // id: '0'
|
|
|
- // });
|
|
|
- // if (res.success) {
|
|
|
- // this.classList = res.data;
|
|
|
- // if (this.selectNode) {
|
|
|
- // this.$nextTick(() => {
|
|
|
- // this.convertTreeData(res.data);
|
|
|
- // if (!this.selectNode.hasOwnProperty('children')) {
|
|
|
- // this.urlIdList = [];
|
|
|
- // this.urlIdList.push(this.selectNode.id);
|
|
|
- // let parentId = this.selectNode.parentId;
|
|
|
- // this.deepEach(parentId);
|
|
|
- // this.itemForm.urlIdList = this.urlIdList.reverse();
|
|
|
- // }
|
|
|
- // });
|
|
|
- // }
|
|
|
- // }
|
|
|
- // } catch (error) {}
|
|
|
- },
|
|
|
-
|
|
|
convertTreeData (data) {
|
|
|
this.changeData = data;
|
|
|
for (let i = 0; i < this.changeData.length; i++) {
|
|
|
@@ -337,23 +303,13 @@
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- // 子节点处理
|
|
|
- deepEach (parentId) {
|
|
|
- this.changeData.map((item, index) => {
|
|
|
- if (item.id == parentId) {
|
|
|
- this.urlIdList.push(item.id);
|
|
|
- this.deepEach(item.parentId); // 递归
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
-
|
|
|
setDefault (val) {
|
|
|
this.$refs.itemMatchRef && this.$refs.itemMatchRef.setDefault(val);
|
|
|
},
|
|
|
|
|
|
initItemForm () {
|
|
|
this.itemForm = {
|
|
|
- classificationUrlId: [],
|
|
|
+ categoryLevelPathId: [],
|
|
|
addList: [],
|
|
|
info: { angle: 'notA' },
|
|
|
urlIdList: [],
|