From 209d9c6f60d96fc29fad0bd2f9dad8fe8424f91f Mon Sep 17 00:00:00 2001
From: futian.liu <liufutianyoo@163.com>
Date: 星期五, 17 十一月 2023 18:10:47 +0800
Subject: [PATCH] 调拨管理
---
admin-web/src/views/stock/accessStock/outbound/edit.vue | 297 ++++++++++++++++++++++++----------------------------------
1 files changed, 123 insertions(+), 174 deletions(-)
diff --git a/admin-web/src/views/stock/accessStock/outbound/edit.vue b/admin-web/src/views/stock/accessStock/outbound/edit.vue
index 22d1448..1521f03 100644
--- a/admin-web/src/views/stock/accessStock/outbound/edit.vue
+++ b/admin-web/src/views/stock/accessStock/outbound/edit.vue
@@ -1,19 +1,24 @@
<template>
- <win-md class="stock-edit" :title="`${setting.title}鍑哄簱鍑哄簱`" @close="close" :width="'800px'">
+ <win-md class="stock-edit" :title="`${setting.title}鍑哄簱`" @close="close" :width="'800px'">
<el-form class="form" ref="ruleForm" :model="formData" :rules="rules" label-width="120px">
<div class="main-w">
<el-row :gutter="24" class="headerHeight">
<el-col :span="12">
<el-form-item label="鍑哄簱浠撳簱" prop="warehouseId">
<el-select v-model="formData.warehouseId" placeholder="璇烽�夋嫨" style="width: 100%">
- <el-option v-for="item in warehouses" :key="item.id" :label="item.warehouseName" :value="item.id" />
+ <el-option
+ v-for="item in warehouseOptions"
+ :key="item.id"
+ :label="item.warehouseName"
+ :value="item.id"
+ />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
- <el-form-item label="鍑哄簱鏃堕棿" prop="procureTime">
+ <el-form-item label="鍑哄簱鏃堕棿" prop="dealTime">
<el-date-picker
- v-model="formData.procureTime"
+ v-model="formData.dealTime"
type="datetime"
value="yyyy-MM-dd HH:mm:ss"
value-format="yyyyMMddHHmmss"
@@ -25,18 +30,18 @@
</el-col>
</el-row>
<el-row :gutter="24" class="headerHeight">
- <el-col :span="12">
+ <el-col :span="24">
<el-form-item label="鍑哄簱鎵嬬画" prop="procureDoc">
- <upload :settings="uploadSettings" @on-change="uploadChange"></upload>
+ <upload ref="uploadRef" :settings="uploadSettings" @on-change="uploadChange"></upload>
</el-form-item>
</el-col>
</el-row>
- <div class="goods-card" v-for="(goodsItem, goodsIndex) in formData.procureGoods" :key="goodsIndex">
+ <div class="goods-card" v-for="(goodsItem, goodsIndex) in formData.goods" :key="goodsIndex">
<el-row :gutter="24">
<el-col :span="12">
<el-form-item
label="鐗╁搧鍒嗙被"
- :prop="`procureGoods[${goodsIndex}].baseCategoryIds`"
+ :prop="`goods[${goodsIndex}].baseCategoryIds`"
:rules="{
required: true,
message: '璇烽�夋嫨',
@@ -55,12 +60,8 @@
<el-col :span="12">
<el-form-item
label="鐗╁搧鍚嶇О"
- :prop="`procureGoods[${goodsIndex}].baseGoodsTemplateId`"
- :rules="{
- required: true,
- message: '璇烽�夋嫨',
- trigger: 'change',
- }"
+ :prop="`goods[${goodsIndex}].baseGoodsTemplateId`"
+ :rules="rules.baseGoodsTemplateId"
>
<el-select
v-model="goodsItem.baseGoodsTemplateId"
@@ -84,7 +85,7 @@
<el-col :span="12">
<el-form-item
label="瑙勬牸鍨嬪彿"
- :prop="`procureGoods[${goodsIndex}].modelsIds`"
+ :prop="`goods[${goodsIndex}].modelsIds`"
:rules="{
required: true,
message: '璇烽�夋嫨',
@@ -122,23 +123,30 @@
</template>
</el-table-column>
<el-table-column prop="price" label="鐜版湁搴撳瓨" align="center">
- <template slot-scope="scope">{{ }}
+ <template slot-scope="scope">
{{ scope.row.worehouseCount }}
</template>
</el-table-column>
<el-table-column prop="counts" label="鍑哄簱鏁伴噺" align="center">
<template slot-scope="scope">
- <el-input
- type="number"
- v-model="scope.row.counts"
- @change="countsChange($event, goodsIndex,scope.$index)"
- ></el-input>
+ <el-form-item
+ label-width="0"
+ style="margin-bottom: 0"
+ :prop="`goods[${goodsIndex}].models[${scope.$index}].counts`"
+ :rules="rules.counts"
+ >
+ <el-input
+ type="number"
+ v-model="scope.row.counts"
+ @change="countsChange($event, goodsIndex, scope.$index)"
+ ></el-input>
+ </el-form-item>
</template>
</el-table-column>
</el-table>
<div class="btn-group">
<el-button
- v-if="formData.procureGoods.length > 1"
+ v-if="formData.goods.length > 1"
name="绉婚櫎"
type="danger"
plain
@@ -147,7 +155,7 @@
>绉婚櫎</el-button
>
<el-button
- v-if="formData.procureGoods.length - 1 == goodsIndex"
+ v-if="formData.goods.length - 1 == goodsIndex"
name="鏂板鐗╁搧"
type="primary"
plain
@@ -168,19 +176,17 @@
<script>
import {
goodsTemplate,
- procureAdd,
- procureEdit,
- selectTenantWarehouse,
goodsModel,
- procureDetail,
-} from '@/api/stock/procure/purchaseOrder';
+ selectTenantWarehouse,
+ warehouseSelectNumber,
+} from '@/api/baseSetting/finsystenant';
+import { outputAdd } from '@/api/stock/accessStock';
import { getTree } from '@/api/foudation/classification';
import MyButton from '@/components/myButton/myButton';
import winMd from '@/components/win/win-md';
import upload from '@/components/upload/index';
import { getUploadUrl } from '@/utils/base';
-
-import SettingIplatform from '../../../../../public/static/config';
+import { mapGetters } from 'vuex';
export default {
components: { MyButton, winMd, upload },
@@ -191,36 +197,34 @@
},
},
data() {
+ // 鑷畾涔夋牎楠�
+ // 鐗╁搧閲嶅鏍¢獙
+ var checkGoodsTemplateId = (rule, value, callback) => {
+ if (!value) {
+ return callback(new Error('璇烽�夋嫨'));
+ }
+ let temp = this.formData.goods.filter((v) => v.baseGoodsTemplateId == value);
+ if (!temp || temp.length != 1) {
+ return callback(new Error('宸查�夎繃姝ょ墿鍝�'));
+ }
+ callback();
+ };
return {
- visible: false,
loading: false,
- buyTypeOptions: [
- {
- label: '闆嗛噰',
- value: '1',
- },
- {
- label: '鑷噰',
- value: '2',
- },
- ],
- warehouses: [], // 鍑哄簱浠撳簱鍒楄〃
+ warehouseOptions: [], // 鍑哄簱浠撳簱鍒楄〃
categoryOptions: [], // 鐗╁搧鍒嗙被鍒楄〃
modelList: [], //鍨嬪彿鍒楄〃
formData: {
warehouseId: '', // 鍑哄簱浠撳簱id
- procureTime: '', // 鍑哄簱鏃堕棿
- buyType: '2', // 鍑哄簱鏂瑰紡锛�1锛氶泦閲囷紱2=鑷噰锛�
- procureGoods: [],
+ dealTime: '', // 鍑哄簱鏃堕棿
+ procureDoc: '',
+ goods: [],
},
goodsItem: {
- whFormProcureId: '', // 鍑哄簱鍗旾D
baseCategoryIds: '', // 鍒嗙被缂栧彿鏁扮粍
baseCategoryId: '', // 鍒嗙被缂栧彿
baseGoodsTemplateId: '', // 鐗╁搧妯$増缂栧彿
goodsTemplateName: '', // 鐗╁搧妯$増鍚嶇О
- supplier: '', // 渚涘簲鍟�
- sort: '', // 鏄剧ず椤哄簭
goodsOptions: [], // 鐗╁搧鍒楄〃select
modelsOptions: [], //瑙勬牸鍨嬪彿select
models: [], // 鐗╁搧鍚嶇О
@@ -228,35 +232,36 @@
},
modelsItem: {
baseGoodsModelsId: '', // 瑙勬牸鍨嬪彿缂栧彿
- price: 0, // 鍗曚环(鍑哄簱闇�瑕侊紝璋冩嫧涓嶉渶瑕�)
worehouseCount: 0,
- counts: 0, // 鎿嶄綔鏁伴噺
- supplier: '', // 渚涘簲鍟�
+ counts: null, // 鎿嶄綔鏁伴噺
unit: null, //鍗曚綅
},
rules: {
warehouseId: [{ required: true, message: '璇烽�夋嫨', trigger: 'change' }],
- procureTime: [{ required: true, message: '璇烽�夋嫨', trigger: 'change' }],
+ dealTime: [{ required: true, message: '璇烽�夋嫨', trigger: 'change' }],
buyType: [{ required: true, message: '璇烽�夋嫨', trigger: 'change' }],
- // procureDoc: [{ required: true, message: '璇蜂笂浼�', trigger: 'change' }],
baseCategoryIds: [{ required: true, message: '璇烽�夋嫨', trigger: 'change' }],
- baseGoodsTemplateId: [{ required: true, message: '璇烽�夋嫨', trigger: 'change' }],
+ baseGoodsTemplateId: [{ validator: checkGoodsTemplateId, trigger: ['blur', 'change'] }],
modelsIds: [{ required: true, message: '璇烽�夋嫨', trigger: 'change' }],
+ counts: [{ required: true, message: '璇疯緭鍏�', trigger: 'change' }],
},
uploadSettings: {
title: '涓婁紶',
max: 20, // 鏈�澶уぇ灏忥紝鍗曚綅M
- num: 2, // 鏀寔涓婁紶鍥剧墖涓暟
+ num: 10, // 鏀寔涓婁紶鍥剧墖涓暟
accept: '.jpg,.png', // 闄愬埗鏍煎紡
tip: '', // 鎻愮ず 榛樿锛歚鍙兘涓婁紶${this.defaultSettings.num}涓�${this.defaultSettings.accept}鏂囦欢锛屼笖涓嶈秴杩�${this.defaultSettings.max}kb`
uploadUrl: getUploadUrl(), // 涓婁紶璺緞
multiple: true, // 鏄惁鏀寔鎵归噺涓婁紶
disabled: false, // 鏄惁绂佺敤
- type: 'text', // text/picture
+ type: 'picture', // text/picture
},
};
+ },
+ computed: {
+ ...mapGetters(['userInfo']),
},
created() {
this.init();
@@ -269,39 +274,19 @@
// 鑾峰彇鐗╁搧鍒嗙被鍒楄〃
const treeRes = await getTree();
this.categoryOptions = this.removeEmptyChildren(treeRes);
- if (this.setting.id) {
- const detail = await procureDetail({ id: this.setting.id });
- this.formData = Object.assign(this.formData, detail);
- this.$set(this.formData, 'buyType', this.formData.buyType.toString());
- this.formData.procureTime = this.formData.procureTime.toString();
- this.formData.procureGoods.map((item, index) => {
- // 鏍规嵁瀛愰泦ID鎷兼帴鐗╁搧鍒嗙被鍒楄〃
- let pIds = this.findParentIds(this.categoryOptions, item.baseCategoryId);
- pIds = pIds.reverse();
- item.baseCategoryIds = [...pIds, item.baseCategoryId];
- this.$set(
- this.formData.procureGoods[index],
- 'modelsIds',
- item.models.map((v) => v.baseGoodsModelsId),
- );
- this.getgoodsTemplate(item.baseCategoryId, index);
- this.getgoodsModel(item.baseGoodsTemplateId, index);
- return item;
- });
- } else {
- this.formData.procureGoods.push(JSON.parse(JSON.stringify(this.goodsItem)));
- }
- this.visible = true;
},
// 鑾峰彇鍑哄簱浠撳簱鍒楄〃
getWarehouseList() {
- selectTenantWarehouse()
+ selectTenantWarehouse({ agencyId: this.userInfo.tenantId })
.then((res) => {
- this.warehouses = res;
- if (this.warehouses.length && !this.formData.warehouseId) {
+ this.warehouseOptions = res;
+ if (res.length) {
+ this.formData.goods.push(JSON.parse(JSON.stringify(this.goodsItem)));
+ }
+ if (this.warehouseOptions.length && !this.formData.warehouseId) {
// 榛樿閫変腑绗竴涓粨搴�
- this.formData.warehouseId = this.warehouses[0].id;
+ this.formData.warehouseId = this.warehouseOptions[0].id;
}
})
.catch((err) => {
@@ -324,7 +309,7 @@
getgoodsTemplate(id, index) {
goodsTemplate({ categoryId: id || '' }).then((res) => {
if (index || index == 0) {
- this.$set(this.formData.procureGoods[index], 'goodsOptions', res);
+ this.$set(this.formData.goods[index], 'goodsOptions', res);
} else {
this.goodsTemplatelAll = res;
}
@@ -335,7 +320,7 @@
getgoodsModel(id, index) {
goodsModel({ goodsTemplatesId: id || '' }).then((res) => {
if (index || index == 0) {
- this.$set(this.formData.procureGoods[index], 'modelsOptions', res);
+ this.$set(this.formData.goods[index], 'modelsOptions', res);
} else {
this.goodsModelAll = res;
}
@@ -362,71 +347,84 @@
// 鐗╁搧鍒嗙被閫夋嫨
categoryChange(e, index) {
- this.formData.procureGoods[index].goodsOptions = [];
- this.formData.procureGoods[index].baseGoodsTemplateId = '';
- this.formData.procureGoods[index].goodsTemplateName = '';
- this.formData.procureGoods[index].modelsOptions = [];
- this.formData.procureGoods[index].modelsIds = [];
- this.formData.procureGoods[index].models = [];
+ this.formData.goods[index].goodsOptions = [];
+ this.formData.goods[index].baseGoodsTemplateId = '';
+ this.formData.goods[index].goodsTemplateName = '';
+ this.formData.goods[index].modelsOptions = [];
+ this.formData.goods[index].modelsIds = [];
+ this.formData.goods[index].models = [];
- this.formData.procureGoods[index].baseCategoryId = e[e.length - 1];
+ this.formData.goods[index].baseCategoryId = e[e.length - 1];
// 鏍规嵁閫変腑鍒嗙被璇锋眰鐗╁搧鍚嶇О鍒楄〃
this.getgoodsTemplate(e[e.length - 1], index);
},
- // 鐗╁搧鍚嶇О鍒楄〃
+ // 鐗╁搧鍚嶇О鍒楄〃閫夋嫨
goodsTemplateChange(e, index) {
- this.formData.procureGoods[index].modelsOptions = [];
- this.formData.procureGoods[index].modelsIds = [];
- this.formData.procureGoods[index].models = [];
+ this.formData.goods[index].modelsOptions = [];
+ this.formData.goods[index].modelsIds = [];
+ this.formData.goods[index].models = [];
- this.formData.procureGoods[index].goodsTemplateName = this.getGoodsTemplateName(e);
+ this.formData.goods[index].goodsTemplateName = this.getGoodsTemplateName(e);
// 鏍规嵁閫変腑鐗╁搧鍚嶇Оid鑾峰彇瑙勬牸鍨嬪彿鍒楄〃
this.getgoodsModel(e, index);
},
// 瑙勬牸鍨嬪彿閫夋嫨
- modelChange(e, index) {
- let arr = [...this.formData.procureGoods[index].models];
+ async modelChange(e, index) {
+ let arr = [...this.formData.goods[index].models];
let str = JSON.stringify(arr);
- e.forEach((item) => {
+ for (let item of e) {
if (str.indexOf(item) == -1) {
let temp = this.goodsModelAll.find((v) => v.id == item);
- arr.push({ ...this.modelsItem, baseGoodsModelsId: item, unit: temp.unit });
+ // 鑾峰彇搴撳瓨
+ let num = await warehouseSelectNumber({
+ warehouseId: this.formData.warehouseId,
+ baseGoodsModelsId: item,
+ warehouseType: 0,
+ states: 1,
+ buyType: null,
+ });
+ arr.push({ ...this.modelsItem, baseGoodsModelsId: item, unit: temp.unit, worehouseCount: num });
}
- });
- this.formData.procureGoods[index].models = arr;
+ }
+ this.formData.goods[index].models = arr;
},
// 瑙勬牸鍨嬪彿绉婚櫎
modelRemoveTag(e, index) {
- let arr = this.formData.procureGoods[index].models;
+ let arr = this.formData.goods[index].models;
let delIndex = arr.findIndex((v) => v.baseGoodsModelsId == e);
- this.formData.procureGoods[index].models.splice(delIndex, 1);
+ this.formData.goods[index].models.splice(delIndex, 1);
},
// 涓婁紶
- uploadChange(e) {
- console.log('uploadChange', e);
+ uploadChange() {
+ let arr = this.$refs.uploadRef.fileList;
+ this.formData.procureDoc = JSON.stringify(arr);
},
// 鐐瑰嚮鏂板鐗╁搧
addGoods() {
- this.formData.procureGoods.push(JSON.parse(JSON.stringify(this.goodsItem)));
+ this.formData.goods.push(JSON.parse(JSON.stringify(this.goodsItem)));
},
// 鐐瑰嚮绉婚櫎
removeGoods(index) {
- this.formData.procureGoods.splice(index, 1);
+ this.formData.goods.splice(index, 1);
},
// 鍑哄簱鏁伴噺鏍¢獙
- countsChange(e, goodsIndex,index) {
- const curItem = this.formData.procureGoods[goodsIndex].models[index]
- const worehouseCount = curItem.worehouseCount
+ countsChange(e, goodsIndex, index) {
+ const curItem = this.formData.goods[goodsIndex].models[index];
+ const worehouseCount = curItem.worehouseCount;
+ if (e == 0) {
+ this.$message.warning('鏁伴涓嶈兘涓�0');
+ curItem.counts = null;
+ }
if (e > worehouseCount) {
this.$message.warning('鏁伴瓒呰繃鐜版湁搴撳瓨');
- curItem.counts = worehouseCount
+ curItem.counts = worehouseCount > 0 ? worehouseCount : null;
}
},
@@ -435,29 +433,16 @@
this.$refs['ruleForm'].validate((valid) => {
if (valid) {
console.log('this.formData', this.formData);
- if (this.setting.id) {
- procureAdd(this.formData)
- .then((res) => {
- this.$message.success('淇濆瓨鎴愬姛锛�');
- this.close();
- this.$emit('search');
- })
- .catch((err) => {
- console.log('create err', err);
- this.$message.error('淇濆瓨澶辫触');
- });
- } else {
- procureEdit(this.formData)
- .then((res) => {
- this.$message.success('淇濆瓨鎴愬姛锛�');
- this.close();
- this.$emit('search');
- })
- .catch((err) => {
- console.log('edit err', err);
- this.$message.error('淇濆瓨澶辫触');
- });
- }
+ outputAdd(this.formData)
+ .then((res) => {
+ this.$message.success('淇濆瓨鎴愬姛锛�');
+ this.close();
+ this.$emit('search');
+ })
+ .catch((err) => {
+ console.log('edit err', err);
+ this.$message.error('淇濆瓨澶辫触');
+ });
} else {
this.$message.error('鏍¢獙鏈�氳繃锛岃妫�鏌ャ��');
}
@@ -467,46 +452,10 @@
close() {
this.formData = {
warehouseId: '', // 鍑哄簱浠撳簱id
- procureTime: '', // 鍑哄簱鏃堕棿
- procureGoods: [],
+ dealTime: '', // 鍑哄簱鏃堕棿
+ goods: [],
};
this.$emit('close');
- },
-
- // 閫氳繃瀛愰泦id鏌ュ埌鎵�浠ョ浉鍏崇埗绾d骞惰繑鍥炴暟缁�
- findParentIds(dataSource, nodeId) {
- const parentIds = []; // 鐢ㄤ簬瀛樺偍鎵�鏈夌埗鑺傜偣ID鐨勬暟缁�
-
- // 瀹氫箟涓�涓�掑綊鍑芥暟锛岀敤浜庨亶鍘嗘暣妫垫爲骞舵煡鎵惧瓙鑺傜偣鐨勬墍鏈夌埗鑺傜偣
- function traverse(node, nodeId) {
- if (node.id === nodeId) {
- // 濡傛灉褰撳墠鑺傜偣鐨処D绛変簬瀛愯妭鐐圭殑ID锛屽垯琛ㄧず宸茬粡鎵惧埌浜嗗瓙鑺傜偣锛屽彲浠ュ紑濮嬪悜涓婃煡鎵剧埗鑺傜偣
- return true; // 杩斿洖true琛ㄧず宸茬粡鎵惧埌浜嗗瓙鑺傜偣
- }
-
- if (node.children) {
- // 濡傛灉褰撳墠鑺傜偣鏈夊瓙鑺傜偣锛屽垯缁х画閬嶅巻瀛愯妭鐐�
- for (const childNode of node.children) {
- if (traverse(childNode, nodeId)) {
- // 濡傛灉鍦ㄥ瓙鑺傜偣涓壘鍒颁簡瀛愯妭鐐圭殑鐖惰妭鐐癸紝鍒欏皢褰撳墠鑺傜偣鐨処D娣诲姞鍒扮埗鑺傜偣ID鏁扮粍涓紝骞惰繑鍥瀟rue琛ㄧず宸茬粡鎵惧埌浜嗗瓙鑺傜偣
- parentIds.push(node.id);
- return true;
- }
- }
- }
-
- return false; // 濡傛灉褰撳墠鑺傜偣涓嶆槸瀛愯妭鐐圭殑鐖惰妭鐐癸紝鍒欒繑鍥瀎alse
- }
-
- // 浠庢牴鑺傜偣寮�濮嬮亶鍘嗘暣妫垫爲锛屽苟璋冪敤閫掑綊鍑芥暟鏌ユ壘瀛愯妭鐐圭殑鎵�鏈夌埗鑺傜偣
- for (const node of dataSource) {
- if (traverse(node, nodeId)) {
- // 濡傛灉鍦ㄥ綋鍓嶈妭鐐圭殑瀛愭爲涓壘鍒颁簡瀛愯妭鐐圭殑鐖惰妭鐐癸紝鍒欑洿鎺ラ��鍑哄惊鐜�
- break;
- }
- }
-
- return parentIds; // 杩斿洖鎵�鏈夌埗鑺傜偣ID鐨勬暟缁�
},
},
};
--
Gitblit v1.9.1