|
@@ -17,20 +17,22 @@
|
|
|
<search-supplier
|
|
|
:value="ruleForm.supplier_code"
|
|
|
:placeholder="'请选择公司'"
|
|
|
+ :is-detail="id !== 'add'"
|
|
|
+ :disabled="!(id === 'add')"
|
|
|
:names="supplier_name"
|
|
|
- @searchChange="selectSupplier"
|
|
|
+ @searchChange="selectSupplierOut"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="仓库" prop="stock_code">
|
|
|
<search-stock
|
|
|
:value="ruleForm.stock_code"
|
|
|
- :isDetail="true"
|
|
|
- :disabled="isDisabled"
|
|
|
+ :isDetail="id !== 'add'"
|
|
|
+ :disabled="!(id === 'add')"
|
|
|
:placeholder="'请选择仓库'"
|
|
|
:isRelation="true"
|
|
|
:companyCode="supplier_code"
|
|
|
:names="''"
|
|
|
- @searchChange="selectStock"
|
|
|
+ @searchChange="selectStockOut"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
@@ -40,6 +42,13 @@
|
|
|
<search-supplier
|
|
|
:value="ruleForm.supplier_in_code"
|
|
|
:placeholder="'请选择公司'"
|
|
|
+ :is-detail="id !== 'add'"
|
|
|
+ :disabled="
|
|
|
+ !(
|
|
|
+ id === 'add' ||
|
|
|
+ (status === '0' && powers.some((item) => item == '005'))
|
|
|
+ )
|
|
|
+ "
|
|
|
:names="supplier_in_name"
|
|
|
@searchChange="selectSupplierIn"
|
|
|
/>
|
|
@@ -47,133 +56,189 @@
|
|
|
<el-form-item label="仓库" prop="stock_in_code">
|
|
|
<search-stock
|
|
|
:value="ruleForm.stock_in_code"
|
|
|
- :isDetail="true"
|
|
|
- :disabled="isDisabledIn"
|
|
|
+ :isDetail="id !== 'add'"
|
|
|
+ :disabled="
|
|
|
+ !(
|
|
|
+ id === 'add' ||
|
|
|
+ (status === '0' && powers.some((item) => item == '005'))
|
|
|
+ )
|
|
|
+ "
|
|
|
:placeholder="'请选择仓库'"
|
|
|
:isRelation="true"
|
|
|
- :companyCode="stock_in_code"
|
|
|
+ :companyCode="supplier_in_code"
|
|
|
:names="''"
|
|
|
@searchChange="selectStockIn"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
-
|
|
|
- <el-form-item
|
|
|
- label="商品"
|
|
|
- prop="product_go"
|
|
|
+ </el-form>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-row v-if="status == '' || status == '0'">
|
|
|
+ <el-col :span="24" style="padding: 0 0 10px 0">
|
|
|
+ <span>调拨商品:</span>
|
|
|
+ <el-button
|
|
|
+ :size="'mini'"
|
|
|
+ type="primary"
|
|
|
+ class="fr"
|
|
|
+ @click="openGoodsModel"
|
|
|
+ >添加商品</el-button
|
|
|
+ ></el-col
|
|
|
+ >
|
|
|
+ </el-row>
|
|
|
+ <!-- v-if="status === '0'" -->
|
|
|
+ <el-form
|
|
|
+ :model="tableForm"
|
|
|
+ :rules="tableFormThis"
|
|
|
+ v-if="
|
|
|
+ !(
|
|
|
+ (status == '3' && powers.some((item) => item == '022')) ||
|
|
|
+ (status == '4' && powers.some((item) => item == '023'))
|
|
|
+ )
|
|
|
+ "
|
|
|
+ ref="tableForm"
|
|
|
+ :size="'mini'"
|
|
|
+ class="demo-tableForm product_go"
|
|
|
+ >
|
|
|
+ <el-table
|
|
|
+ :data="tableForm.product_go"
|
|
|
+ border
|
|
|
:size="'mini'"
|
|
|
- class="product_go"
|
|
|
+ row-key="key"
|
|
|
>
|
|
|
- <el-row>
|
|
|
- <el-col :span="24" style="padding: 0 0 10px 0">
|
|
|
- <el-button
|
|
|
- :size="'mini'"
|
|
|
- type="primary"
|
|
|
- class="fr"
|
|
|
- @click="openGoodsModel"
|
|
|
- >添加商品</el-button
|
|
|
- ></el-col
|
|
|
+ <template v-for="(item, index) in columns">
|
|
|
+ <el-table-column
|
|
|
+ :prop="item.prop"
|
|
|
+ show-overflow-tooltip
|
|
|
+ :label="item.label"
|
|
|
+ v-if="
|
|
|
+ item.type === 'text' && item.show && item.prop !== 'error_code'
|
|
|
+ "
|
|
|
+ :width="item.width"
|
|
|
+ :min-width="item.minWidth"
|
|
|
+ :key="item.prop + index"
|
|
|
+ />
|
|
|
+ <el-table-column
|
|
|
+ :prop="item.prop"
|
|
|
+ :label="item.label"
|
|
|
+ v-else-if="
|
|
|
+ item.type === 'text' && item.show && item.prop === 'error_code'
|
|
|
+ "
|
|
|
+ :width="item.width"
|
|
|
+ :min-width="item.minWidth"
|
|
|
+ :key="item.prop + index"
|
|
|
>
|
|
|
- <el-col :span="24">
|
|
|
- <!-- row-key="key" -->
|
|
|
- <el-table
|
|
|
- :data="ruleForm.product_go"
|
|
|
- border
|
|
|
- :size="'mini'"
|
|
|
- row-key="key"
|
|
|
- max-height="400px"
|
|
|
- >
|
|
|
- <template v-for="(item, index) in columns">
|
|
|
- <el-table-column
|
|
|
- v-if="item.prop !== 'allot_num'"
|
|
|
- show-overflow-tooltip
|
|
|
- :prop="item.prop"
|
|
|
- :label="item.label"
|
|
|
- :width="item.width"
|
|
|
- :min-width="item.minWidth"
|
|
|
- :key="item.prop + index"
|
|
|
- >
|
|
|
- </el-table-column>
|
|
|
- <el-table-column
|
|
|
- :prop="item.prop"
|
|
|
- :label="item.label"
|
|
|
- :width="item.width"
|
|
|
- :min-width="item.minWidth"
|
|
|
- :key="item.prop + index"
|
|
|
- v-else
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <span class="spscope">{{ scope.row.error_code_name }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ :prop="item.prop"
|
|
|
+ :label="item.label"
|
|
|
+ v-else-if="item.type !== 'text' && item.show"
|
|
|
+ :width="item.width"
|
|
|
+ :min-width="item.minWidth"
|
|
|
+ :key="item.prop + index"
|
|
|
+ >
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-form-item
|
|
|
+ :prop="'product_go.' + scope.$index + '.' + item.prop"
|
|
|
+ :rules="scope.row.edit ? tableFormThis[item.prop] : {}"
|
|
|
+ :size="'mini'"
|
|
|
+ >
|
|
|
+ <el-input
|
|
|
+ v-if="scope.row.edit === true && item.type === 'input'"
|
|
|
+ :size="'mini'"
|
|
|
+ maxlength="250"
|
|
|
+ clearable
|
|
|
+ v-model="scope.row[item.prop]"
|
|
|
+ />
|
|
|
+ <el-select
|
|
|
+ v-model="scope.row[item.prop]"
|
|
|
+ v-if="scope.row.edit === true && item.type === 'select'"
|
|
|
+ style="width: 100%"
|
|
|
+ clearable
|
|
|
+ placeholder="异常原因"
|
|
|
+ @change="elSelectChange($event, scope.$index)"
|
|
|
>
|
|
|
- <template slot-scope="scope">
|
|
|
- <el-form-item
|
|
|
- :prop="'list.' + scope.$index + '.' + scope.row.id"
|
|
|
- :size="'mini'"
|
|
|
- >
|
|
|
- <el-input
|
|
|
- :size="'mini'"
|
|
|
- v-model="scope.row[item.prop]"
|
|
|
- v-if="scope.row.edit"
|
|
|
- ></el-input>
|
|
|
- <span v-else class="spscope">{{
|
|
|
- scope.row[item.prop]
|
|
|
- }}</span>
|
|
|
- </el-form-item>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- </template>
|
|
|
-
|
|
|
- <el-table-column fixed="right" label="操作" width="80">
|
|
|
- <template slot-scope="scope">
|
|
|
- <el-tooltip
|
|
|
- effect="dark"
|
|
|
- content="编辑"
|
|
|
- v-if="!scope.row.edit"
|
|
|
- placement="top"
|
|
|
+ <el-option
|
|
|
+ v-for="item in options"
|
|
|
+ :key="item.result_code"
|
|
|
+ :label="item.result"
|
|
|
+ :value="item.result_code"
|
|
|
+ :disabled="item.status === '0'"
|
|
|
>
|
|
|
- <i
|
|
|
- class="el-icon-edit tb-icon"
|
|
|
- @click="editRow(scope.$index)"
|
|
|
- ></i>
|
|
|
- </el-tooltip>
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ <span v-if="!scope.row.edit" class="spscope">{{
|
|
|
+ item.type === "select"
|
|
|
+ ? scope.row.error_code_name
|
|
|
+ : scope.row[item.prop]
|
|
|
+ }}</span>
|
|
|
+ </el-form-item>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </template>
|
|
|
|
|
|
- <el-tooltip
|
|
|
- effect="dark"
|
|
|
- content="保存"
|
|
|
- v-if="scope.row.edit"
|
|
|
- placement="top"
|
|
|
- >
|
|
|
- <i
|
|
|
- class="el-icon-circle-check tb-icon"
|
|
|
- @click="checkRow(scope.$index)"
|
|
|
- ></i>
|
|
|
- </el-tooltip>
|
|
|
+ <el-table-column
|
|
|
+ fixed="right"
|
|
|
+ label="操作"
|
|
|
+ v-if="status === '' || status == '0'"
|
|
|
+ width="80"
|
|
|
+ >
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-tooltip
|
|
|
+ effect="dark"
|
|
|
+ content="编辑"
|
|
|
+ v-if="!scope.row.edit"
|
|
|
+ placement="top"
|
|
|
+ >
|
|
|
+ <i
|
|
|
+ class="el-icon-edit tb-icon"
|
|
|
+ @click="editRow(scope.$index)"
|
|
|
+ ></i>
|
|
|
+ </el-tooltip>
|
|
|
|
|
|
- <el-tooltip effect="dark" content="删除" placement="top">
|
|
|
- <i
|
|
|
- class="el-icon-delete tb-icon"
|
|
|
- @click="deleteRow(scope.$index, ruleForm.product_go)"
|
|
|
- ></i>
|
|
|
- </el-tooltip>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- </el-table>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- </el-form-item>
|
|
|
+ <el-tooltip
|
|
|
+ effect="dark"
|
|
|
+ content="保存"
|
|
|
+ v-if="scope.row.edit"
|
|
|
+ placement="top"
|
|
|
+ >
|
|
|
+ <i
|
|
|
+ class="el-icon-circle-check tb-icon"
|
|
|
+ @click="checkRow(scope.$index)"
|
|
|
+ ></i>
|
|
|
+ </el-tooltip>
|
|
|
+
|
|
|
+ <el-tooltip effect="dark" content="删除" placement="top">
|
|
|
+ <i
|
|
|
+ class="el-icon-delete tb-icon"
|
|
|
+ @click="deleteRow(scope.$index, tableForm.product_go)"
|
|
|
+ ></i>
|
|
|
+ </el-tooltip>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
</el-form>
|
|
|
</el-col>
|
|
|
- <el-col :span="24" style="text-align: right">
|
|
|
+ <el-col :span="24" style="text-align: right; padding: 10px 0 0 0">
|
|
|
<el-button
|
|
|
type="primary"
|
|
|
:size="'mini'"
|
|
|
@click="submitForm"
|
|
|
- v-if="!isDetail"
|
|
|
+ v-if="
|
|
|
+ id === 'add' ||
|
|
|
+ (status === '0' && powers.some((item) => item == '005'))
|
|
|
+ "
|
|
|
>保 存
|
|
|
</el-button>
|
|
|
</el-col>
|
|
|
<el-col :span="24">
|
|
|
<search-stock-good-modal
|
|
|
:show-model="showGoodsModel"
|
|
|
- :code="stockCode"
|
|
|
+ :code="stock_code"
|
|
|
@cancel="showGoodsModel = false"
|
|
|
@searchChange="addGoodsRes"
|
|
|
/>
|
|
@@ -183,32 +248,49 @@
|
|
|
<script>
|
|
|
import asyncRequest from "@/apis/service/stock/allot/detail";
|
|
|
import resToken from "@/mixins/resToken";
|
|
|
+import { isnumber } from "@/utils/validate";
|
|
|
+import config from "./columns"; //表格列参数
|
|
|
export default {
|
|
|
name: "allot",
|
|
|
- props: ["showModel", "id", "isDetail", "sitem"],
|
|
|
+ props: ["showModel", "id", "sitem", "newTime"],
|
|
|
mixins: [resToken],
|
|
|
+ computed: {
|
|
|
+ powers() {
|
|
|
+ let tran =
|
|
|
+ this.$store.getters.btnList.find(
|
|
|
+ (item) => item.menu_route == "allotDetail"
|
|
|
+ ) || {};
|
|
|
+ if (tran && tran.action && tran.action.length > 0) {
|
|
|
+ return tran.action;
|
|
|
+ } else {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
showGoodsModel: false,
|
|
|
status: "",
|
|
|
- // id: "",
|
|
|
supplier_code: "",
|
|
|
- stock_in_code: "",
|
|
|
supplier_name: "",
|
|
|
+ supplier_in_code: "",
|
|
|
supplier_in_name: "",
|
|
|
- isDisabled: true,
|
|
|
- isDisabledIn: true,
|
|
|
+ stock_code: "",
|
|
|
+ stock_in_code: "",
|
|
|
loading: false,
|
|
|
- title: "新建调拨申请",
|
|
|
showModelThis: this.showModel,
|
|
|
+ delList: [],
|
|
|
ruleForm: {
|
|
|
supplier_code: [], //出库供应商code
|
|
|
stock_code: [], //出库仓库code
|
|
|
supplier_in_code: [], //入库供应商code
|
|
|
stock_in_code: [], //入库仓库code
|
|
|
+ },
|
|
|
+ tableForm: {
|
|
|
product_go: [], //出库商品
|
|
|
},
|
|
|
rulesThis: this.rules,
|
|
|
+ tableFormThis: config.tableFormThis,
|
|
|
rules: {
|
|
|
supplier_code: [
|
|
|
{
|
|
@@ -242,115 +324,8 @@ export default {
|
|
|
trigger: "change",
|
|
|
},
|
|
|
],
|
|
|
- product_go: [
|
|
|
- {
|
|
|
- type: "array",
|
|
|
- required: true,
|
|
|
- message: "请选择商品",
|
|
|
- trigger: "change",
|
|
|
- },
|
|
|
- ],
|
|
|
- type_code: [
|
|
|
- {
|
|
|
- required: false,
|
|
|
- message: "",
|
|
|
- trigger: "blur",
|
|
|
- },
|
|
|
- ],
|
|
|
- good_name: [
|
|
|
- {
|
|
|
- required: false,
|
|
|
- message: "",
|
|
|
- trigger: "blur",
|
|
|
- },
|
|
|
- ],
|
|
|
- usable_stock: [
|
|
|
- {
|
|
|
- required: false,
|
|
|
- message: "",
|
|
|
- trigger: "blur",
|
|
|
- },
|
|
|
- ],
|
|
|
- allot_num: [
|
|
|
- {
|
|
|
- required: false,
|
|
|
- message: "",
|
|
|
- trigger: "blur",
|
|
|
- },
|
|
|
- ],
|
|
|
- unit: [
|
|
|
- {
|
|
|
- required: false,
|
|
|
- message: "",
|
|
|
- trigger: "blur",
|
|
|
- },
|
|
|
- ],
|
|
|
- color: [
|
|
|
- {
|
|
|
- required: false,
|
|
|
- message: "",
|
|
|
- trigger: "blur",
|
|
|
- },
|
|
|
- ],
|
|
|
-
|
|
|
- material: [
|
|
|
- {
|
|
|
- required: false,
|
|
|
- message: "",
|
|
|
- trigger: "blur",
|
|
|
- },
|
|
|
- ],
|
|
|
- brand: [
|
|
|
- {
|
|
|
- required: false,
|
|
|
- message: "",
|
|
|
- trigger: "blur",
|
|
|
- },
|
|
|
- ],
|
|
|
},
|
|
|
- columns: [
|
|
|
- {
|
|
|
- prop: "type_code",
|
|
|
- label: "商品编码",
|
|
|
- width: "150",
|
|
|
- },
|
|
|
- {
|
|
|
- prop: "good_name",
|
|
|
- label: "商品名称",
|
|
|
- minWidth: "180",
|
|
|
- },
|
|
|
- {
|
|
|
- prop: "usable_stock",
|
|
|
- label: "可用库存数",
|
|
|
- width: "100",
|
|
|
- },
|
|
|
- {
|
|
|
- prop: "allot_num",
|
|
|
- label: "调拨数量",
|
|
|
- width: "140",
|
|
|
- },
|
|
|
-
|
|
|
- // {
|
|
|
- // prop: "unit",
|
|
|
- // label: "单位",
|
|
|
- // width: "45",
|
|
|
- // },
|
|
|
- // {
|
|
|
- // prop: "color",
|
|
|
- // label: "商品颜色",
|
|
|
- // width: "70",
|
|
|
- // },
|
|
|
- // {
|
|
|
- // prop: "material",
|
|
|
- // label: "商品材质",
|
|
|
- // width: "70",
|
|
|
- // },
|
|
|
- // {
|
|
|
- // prop: "brand",
|
|
|
- // label: "品牌",
|
|
|
- // width: "70",
|
|
|
- // },
|
|
|
- ],
|
|
|
+ columns: [],
|
|
|
tableData: [],
|
|
|
};
|
|
|
},
|
|
@@ -366,6 +341,11 @@ export default {
|
|
|
this.$emit("cancel");
|
|
|
}
|
|
|
},
|
|
|
+ newTime: function (val) {
|
|
|
+ if (val) {
|
|
|
+ this.initForm();
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
mounted() {
|
|
|
console.log("asd");
|
|
@@ -373,11 +353,6 @@ export default {
|
|
|
this.initForm();
|
|
|
},
|
|
|
methods: {
|
|
|
- // 删除行操作
|
|
|
- deleteRow(index, rows) {
|
|
|
- // console.log(index, rows);
|
|
|
- rows.splice(index, 1);
|
|
|
- },
|
|
|
closeModel() {
|
|
|
this.$emit("closeModel");
|
|
|
},
|
|
@@ -387,7 +362,7 @@ export default {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- let index = this.ruleForm.product_go.findIndex((v) => v.edit);
|
|
|
+ let index = this.tableForm.product_go.findIndex((v) => v.edit);
|
|
|
if (index !== -1) {
|
|
|
this.$message.warning("当前已有商品正在编辑!");
|
|
|
return;
|
|
@@ -401,45 +376,87 @@ export default {
|
|
|
if (this.id === "add") {
|
|
|
this.status = "";
|
|
|
}
|
|
|
+ this.columns = [];
|
|
|
this.rulesThis = this.rules;
|
|
|
await this.resetForm();
|
|
|
this.loading = false;
|
|
|
},
|
|
|
-
|
|
|
- async initData() {
|
|
|
- const res = await asyncRequest.detail({ id: this.id });
|
|
|
- if (res && res.code === 0 && res.data) {
|
|
|
- } else if (res && res.code >= 100 && res.code <= 104) {
|
|
|
- await this.logout();
|
|
|
- } else {
|
|
|
- this.$message.warning(res.message);
|
|
|
- }
|
|
|
- },
|
|
|
async resetForm() {
|
|
|
// 重置
|
|
|
await this.$nextTick(() => {
|
|
|
if (this.$refs.ruleForm) {
|
|
|
this.$refs.ruleForm.resetFields();
|
|
|
this.$refs.ruleForm.clearValidate();
|
|
|
- const { item, wsm_in, wsm_out, wsm_in_name, wsm_out_name, status } =
|
|
|
- this.sitem;
|
|
|
- this.supplier_code = wsm_out || "";
|
|
|
- this.stock_in_code = wsm_in || "";
|
|
|
+ const {
|
|
|
+ wsm_in,
|
|
|
+ wsm_out,
|
|
|
+ wsm_in_name,
|
|
|
+ wsm_out_name,
|
|
|
+ status,
|
|
|
+ out_code,
|
|
|
+ in_code,
|
|
|
+ } = this.sitem;
|
|
|
+ this.status = status || "";
|
|
|
+ this.supplier_code = out_code || "";
|
|
|
this.supplier_name = wsm_out_name || "";
|
|
|
+ this.supplier_in_code = in_code || "";
|
|
|
this.supplier_in_name = wsm_in_name || "";
|
|
|
- this.status = status;
|
|
|
+ this.stock_code = wsm_out || "";
|
|
|
+ this.stock_in_code = wsm_in || "";
|
|
|
this.ruleForm = {
|
|
|
- supplier_code: [] || [], //出库供应商code
|
|
|
- stock_code: [wsm_out] || [], //出库仓库code
|
|
|
- supplier_in_code: [] || [], //入库供应商code
|
|
|
- stock_in_code: [wsm_in] || [], //入库仓库code
|
|
|
- product_go: item||[], //出库商品
|
|
|
+ supplier_code: out_code ? [out_code] : [], //出库供应商code
|
|
|
+ stock_code: wsm_out ? [wsm_out] : [], //出库仓库code
|
|
|
+ supplier_in_code: in_code ? [in_code] : [], //入库供应商code
|
|
|
+ stock_in_code: wsm_in ? [wsm_in] : [], //入库仓库code
|
|
|
};
|
|
|
- this.ruleForm.product_go.map((v) => {
|
|
|
- v.usable_stock = v.usable_num;
|
|
|
+ }
|
|
|
+ if (this.$refs.tableForm) {
|
|
|
+ this.$refs.tableForm.resetFields();
|
|
|
+ this.$refs.tableForm.clearValidate();
|
|
|
+ const { item, status } = this.sitem;
|
|
|
+ this.status = status || "";
|
|
|
+ this.tableForm.product_go = [];
|
|
|
+ this.delList = [];
|
|
|
+ let list = JSON.parse(JSON.stringify(item || []));
|
|
|
+ list.forEach((v) => {
|
|
|
+ v.usable_num = v.usable_num;
|
|
|
v.type_code = v.good_type_code;
|
|
|
- v.edit = false
|
|
|
- return v;
|
|
|
+ v.error_num = v.error_num || "0";
|
|
|
+ v.error_code = v.error_code || "";
|
|
|
+ v.error_code_name = v.error_code_name || "";
|
|
|
+ v.error_remark = v.error_remark || "";
|
|
|
+ v.stock_num = v.stock_num || "0";
|
|
|
+ v.edit = false;
|
|
|
+ this.tableForm.product_go.push(v);
|
|
|
+ });
|
|
|
+ let columnsList = JSON.parse(JSON.stringify(config.columns));
|
|
|
+ columnsList.forEach((v1) => {
|
|
|
+ if (this.status == "5" || this.status == "4") {
|
|
|
+ v1.show = true;
|
|
|
+ }
|
|
|
+ if (this.status == "4" && v1.prop === "stock_num") {
|
|
|
+ v1.type = "input";
|
|
|
+ v1.width = "150px";
|
|
|
+ }
|
|
|
+ if (this.status == "3") {
|
|
|
+ if (v1.prop === "error_remark" || v1.prop === "error_num") {
|
|
|
+ v1.show = true;
|
|
|
+ v1.width = "150px";
|
|
|
+ v1.type = "input";
|
|
|
+ }
|
|
|
+ if (v1.prop === "error_code") {
|
|
|
+ v1.show = true;
|
|
|
+ v1.width = "150px";
|
|
|
+ v1.type = "select";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (this.status == "0") {
|
|
|
+ if (v1.prop === "allot_num") {
|
|
|
+ v1.width = "150px";
|
|
|
+ v1.type = "input";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.columns.push(v1);
|
|
|
});
|
|
|
}
|
|
|
});
|
|
@@ -448,24 +465,23 @@ export default {
|
|
|
async submitForm() {
|
|
|
await this.$refs.ruleForm.validate(async (valid) => {
|
|
|
if (valid) {
|
|
|
- if (this.stockCode == this.stock_in_code) {
|
|
|
+ if (this.stock_code == this.stock_in_code) {
|
|
|
this.$message.warning("出入库仓库不能相同!");
|
|
|
return;
|
|
|
}
|
|
|
+ if (this.tableForm.product_go.length === 0) {
|
|
|
+ this.$message.warning("请选择调拨商品!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
let index = -1,
|
|
|
isok = true,
|
|
|
ishas = true,
|
|
|
good = [];
|
|
|
- this.ruleForm.product_go.forEach((v, i) => {
|
|
|
- let goodModel = {
|
|
|
- good_code: v.type_code,
|
|
|
- allot_num: v.allot_num,
|
|
|
- };
|
|
|
-
|
|
|
+ this.tableForm.product_go.forEach((v, i) => {
|
|
|
if (v.edit && index === -1) {
|
|
|
index = i;
|
|
|
}
|
|
|
- let stock = parseInt(v.usable_stock),
|
|
|
+ let stock = parseInt(v.usable_num),
|
|
|
num = parseInt(v.allot_num);
|
|
|
if (stock === 0) {
|
|
|
ishas = false;
|
|
@@ -473,8 +489,8 @@ export default {
|
|
|
if (num > stock) {
|
|
|
isok = false;
|
|
|
}
|
|
|
- good.push(goodModel);
|
|
|
});
|
|
|
+
|
|
|
if (index !== -1) {
|
|
|
this.$message.warning("当前已有商品正在编辑!");
|
|
|
return;
|
|
@@ -489,7 +505,7 @@ export default {
|
|
|
}
|
|
|
|
|
|
this.loading = true;
|
|
|
-
|
|
|
+ good = this.getGoodList();
|
|
|
const { stock_code, stock_in_code } = JSON.parse(
|
|
|
JSON.stringify(this.ruleForm)
|
|
|
);
|
|
@@ -533,87 +549,126 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+ //提交表单前 商品信息list 汇总
|
|
|
+ getGoodList() {
|
|
|
+ let oldList = JSON.parse(JSON.stringify(this.tableForm.product_go)),
|
|
|
+ dList = JSON.parse(JSON.stringify(this.delList)),
|
|
|
+ resList = [];
|
|
|
+ oldList.forEach((v1) => {
|
|
|
+ let goodModel = {
|
|
|
+ id: v1.id || "",
|
|
|
+ good_code: v1.type_code,
|
|
|
+ allot_num: v1.allot_num,
|
|
|
+ is_del: false,
|
|
|
+ };
|
|
|
+ resList.push(goodModel);
|
|
|
+ });
|
|
|
+ dList.forEach((v2) => {
|
|
|
+ let goodModel = {
|
|
|
+ id: v2.id || "",
|
|
|
+ good_code: v2.type_code,
|
|
|
+ allot_num: v2.allot_num,
|
|
|
+ is_del: true,
|
|
|
+ };
|
|
|
+ resList.push(goodModel);
|
|
|
+ });
|
|
|
+ return resList;
|
|
|
+ },
|
|
|
+ // 删除行操作
|
|
|
+ deleteRow(index, rows) {
|
|
|
+ console.log(rows[index]);
|
|
|
+ if (this.id !== "add" && rows[index].id) {
|
|
|
+ this.delList.push(rows[index]);
|
|
|
+ }
|
|
|
+ rows.splice(index, 1);
|
|
|
+ },
|
|
|
//保存某一行
|
|
|
checkRow(rowIndex) {
|
|
|
- const { usable_stock, allot_num } = this.ruleForm.product_go[rowIndex];
|
|
|
- let num = allot_num === "" ? "0" : allot_num;
|
|
|
- if (allot_num === "0") {
|
|
|
- this.$message.warning("调拨数量不能为0!");
|
|
|
+ const { usable_num, allot_num } = this.tableForm.product_go[rowIndex];
|
|
|
+ if (!isnumber(allot_num)) {
|
|
|
+ this.$message.warning("请输入数字!");
|
|
|
return;
|
|
|
}
|
|
|
- if (allot_num === "") {
|
|
|
- this.$message.warning("调拨数量不能为空!");
|
|
|
+ if (allot_num === "0") {
|
|
|
+ this.$message.warning("调拨数量不能为0!");
|
|
|
return;
|
|
|
}
|
|
|
- if (parseInt(num) > parseInt(usable_stock)) {
|
|
|
+ if (parseInt(allot_num) > parseInt(usable_num)) {
|
|
|
this.$message.warning("调拨数量不大于可用库存数!");
|
|
|
return;
|
|
|
}
|
|
|
- this.ruleForm.product_go[rowIndex].edit = false;
|
|
|
+ this.tableForm.product_go[rowIndex].edit = false;
|
|
|
},
|
|
|
//编辑某一行
|
|
|
editRow(rowIndex) {
|
|
|
- let index = this.ruleForm.product_go.findIndex((v) => v.edit);
|
|
|
+ console.log(this.tableForm.product_go);
|
|
|
+ let index = this.tableForm.product_go.findIndex((v) => v.edit);
|
|
|
if (index !== -1) {
|
|
|
this.$message.warning("请完成其他行的编辑!");
|
|
|
return;
|
|
|
} else {
|
|
|
- this.ruleForm.product_go[rowIndex].edit = true;
|
|
|
+ this.tableForm.product_go[rowIndex].edit = true;
|
|
|
}
|
|
|
- console.log(index);
|
|
|
},
|
|
|
// 执行点击商品名称的抛出事件
|
|
|
addGoodsRes(e) {
|
|
|
- let oldList = JSON.parse(JSON.stringify(this.ruleForm.product_go)),
|
|
|
+ let oldList = JSON.parse(JSON.stringify(this.tableForm.product_go)),
|
|
|
addList = JSON.parse(JSON.stringify(e)),
|
|
|
- newList = [].concat(...oldList);
|
|
|
+ newList = [].concat(...oldList),
|
|
|
+ dList = JSON.parse(JSON.stringify(this.delList));
|
|
|
+ console.log(addList);
|
|
|
addList.forEach((v1, index) => {
|
|
|
let oldindex = oldList.findIndex((v2) => v1.type_code === v2.type_code);
|
|
|
if (oldindex === -1) {
|
|
|
+ addList[index].usable_num = addList[index].usable_stock;
|
|
|
addList[index].allot_num = addList[index].usable_stock;
|
|
|
addList[index].edit = false;
|
|
|
newList.push(addList[index]);
|
|
|
}
|
|
|
});
|
|
|
- this.ruleForm.product_go = [].concat(...newList);
|
|
|
- this.$refs.ruleForm.validateField("product_go");
|
|
|
+ newList.forEach((v3) => {
|
|
|
+ let otherindex = dList.findIndex((v4) => v3.type_code === v4.type_code);
|
|
|
+ if (otherindex !== -1) {
|
|
|
+ dList.splice(otherindex, 1);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.tableForm.product_go = [].concat(...newList);
|
|
|
+ this.delList = [].concat(...dList);
|
|
|
+ this.$refs.tableForm.validateField("product_go");
|
|
|
},
|
|
|
|
|
|
- // 选择出库仓库
|
|
|
- selectStock(e) {
|
|
|
- if (e && e.id) {
|
|
|
- this.ruleForm.stock_code = [e.code];
|
|
|
- this.stockCode = e.code;
|
|
|
- } else {
|
|
|
- this.ruleForm.stockCode = [];
|
|
|
- this.stockCode = "";
|
|
|
- }
|
|
|
- this.$refs.ruleForm.validateField("stock_code");
|
|
|
- },
|
|
|
// 选择出库供应商
|
|
|
- selectSupplier(e) {
|
|
|
+ selectSupplierOut(e) {
|
|
|
if (e && e.id) {
|
|
|
this.ruleForm.supplier_code = [e.code];
|
|
|
this.supplier_code = e.code;
|
|
|
- this.isDisabled = false;
|
|
|
} else {
|
|
|
this.ruleForm.supplier_code = [];
|
|
|
this.supplier_code = "";
|
|
|
}
|
|
|
+ this.ruleForm.stock_code = [];
|
|
|
+ this.tableForm.product_go = [];
|
|
|
+ this.delList = [];
|
|
|
this.$refs.ruleForm.validateField("supplier_code");
|
|
|
},
|
|
|
+ // 选择出库仓库
|
|
|
+ selectStockOut(e) {
|
|
|
+ if (e && e.id) {
|
|
|
+ this.ruleForm.stock_code = [e.code];
|
|
|
+ this.stock_code = e.code;
|
|
|
+ } else {
|
|
|
+ this.ruleForm.stock_code = [];
|
|
|
+ this.stock_code = "";
|
|
|
+ }
|
|
|
+ this.tableForm.product_go = [];
|
|
|
+ this.delList = [];
|
|
|
+ this.$refs.ruleForm.validateField("stock_code");
|
|
|
+ },
|
|
|
// 选择入库仓库
|
|
|
selectStockIn(e) {
|
|
|
if (e && e.id) {
|
|
|
this.ruleForm.stock_in_code = [e.code];
|
|
|
this.stock_in_code = e.code;
|
|
|
- if (this.stockCode == this.stock_in_code) {
|
|
|
- this.$message({
|
|
|
- message: "出库供应商仓库不能和入库供应商仓库相同",
|
|
|
- type: "warning",
|
|
|
- });
|
|
|
- return;
|
|
|
- }
|
|
|
} else {
|
|
|
this.ruleForm.stock_in_code = [];
|
|
|
this.stock_in_code = "";
|
|
@@ -624,12 +679,12 @@ export default {
|
|
|
selectSupplierIn(e) {
|
|
|
if (e && e.id) {
|
|
|
this.ruleForm.supplier_in_code = [e.code];
|
|
|
- this.stock_in_code = e.code;
|
|
|
- this.isDisabledIn = false;
|
|
|
+ this.supplier_in_code = e.code;
|
|
|
} else {
|
|
|
this.ruleForm.supplier_in_code = [];
|
|
|
- this.stock_in_code = "";
|
|
|
+ this.supplier_in_code = "";
|
|
|
}
|
|
|
+ this.ruleForm.stock_in_code = [];
|
|
|
this.$refs.ruleForm.validateField("supplier_in_code");
|
|
|
},
|
|
|
},
|