|
@@ -0,0 +1,439 @@
|
|
|
+<template>
|
|
|
+ <div class="addForm">
|
|
|
+ <el-row :gutter="10">
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form
|
|
|
+ :model="ruleForm"
|
|
|
+ status-icon
|
|
|
+ :rules="rulesThis"
|
|
|
+ ref="ruleForm"
|
|
|
+ label-width="150px"
|
|
|
+ class="demo-ruleForm"
|
|
|
+ >
|
|
|
+ <!-- 出库供应商 -->
|
|
|
+ <el-form-item label="出库供应商名称" prop="supplier_code">
|
|
|
+ <search-supplier
|
|
|
+ style="width: calc(100% - 150px)"
|
|
|
+ :value="ruleForm.supplier_code"
|
|
|
+ :placeholder="'请选择供应商'"
|
|
|
+ @searchChange="selectSupplier"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <!-- 出库仓库 -->
|
|
|
+ <el-form-item label="出库仓库名称" prop="stock_code">
|
|
|
+ <search-stock
|
|
|
+ style="width: calc(100% - 150px)"
|
|
|
+ :value="ruleForm.stock_code"
|
|
|
+ :isDetail="true"
|
|
|
+ :disabled="isDisabled"
|
|
|
+ :placeholder="'请选择出口仓库'"
|
|
|
+ :isRelation="true"
|
|
|
+ :companyCode="supplier_code"
|
|
|
+ :names="''"
|
|
|
+ @searchChange="selectStock"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <!-- 入库供应商 -->
|
|
|
+ <el-form-item label="入库供应商名称" prop="supplier_in_code">
|
|
|
+ <search-supplier
|
|
|
+ style="width: calc(100% - 150px)"
|
|
|
+ :value="ruleForm.supplier_in_code"
|
|
|
+ :placeholder="'请选择供应商'"
|
|
|
+ @searchChange="selectSupplierIn"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <!-- 入库仓库 -->
|
|
|
+ <el-form-item label="入库仓库名称" prop="stock_in_code">
|
|
|
+ <search-stock
|
|
|
+ style="width: calc(100% - 150px)"
|
|
|
+ :value="ruleForm.stock_in_code"
|
|
|
+ :isDetail="true"
|
|
|
+ :disabled="isDisabledIn"
|
|
|
+ :placeholder="'请选择入口仓库'"
|
|
|
+ :isRelation="true"
|
|
|
+ :companyCode="stock_in_code"
|
|
|
+ :names="''"
|
|
|
+ @searchChange="selectStockIn"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="出库商品" prop="tableData">
|
|
|
+ <el-table :data="tableData" border :size="'mini'">
|
|
|
+ <el-table-column
|
|
|
+ fixed
|
|
|
+ prop="date"
|
|
|
+ :label="item.label"
|
|
|
+ v-for="(item, index) in columns"
|
|
|
+ :key="index"
|
|
|
+ >
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column fixed="right" label="操作" width="100">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-button
|
|
|
+ @click.native.prevent="deleteRow(scope.$index, tableData)"
|
|
|
+ type="text"
|
|
|
+ size="small"
|
|
|
+ >删除</el-button
|
|
|
+ >
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </el-form-item>
|
|
|
+ isDisabled:{{ isDisabled }}-----isDetail:{{ isDetail }}---id:{{ id }}
|
|
|
+ </el-form>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" style="text-align: right">
|
|
|
+ <el-button type="primary" @click="submitForm" v-if="!isDetail"
|
|
|
+ >保 存
|
|
|
+ </el-button>
|
|
|
+ <el-button @click="closeModel">{{
|
|
|
+ isDetail ? "关 闭" : "取 消"
|
|
|
+ }}</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <!-- <search-good-modal
|
|
|
+ :show-model="showGoodsModel"
|
|
|
+ @cancel="showGoodsModel = false"
|
|
|
+ @resultList="addGoodsRes"
|
|
|
+ /> -->
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+ <script>
|
|
|
+import asyncRequest from "@/apis/service/stock/allot";
|
|
|
+import resToken from "@/mixins/resToken";
|
|
|
+export default {
|
|
|
+ name: "allot",
|
|
|
+ props: ["showModel", "id", "isDetail", "sitem"],
|
|
|
+ mixins: [resToken],
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ supplier_code: "",
|
|
|
+ stock_in_code: "",
|
|
|
+ isDisabled: true,
|
|
|
+ isDisabledIn: true,
|
|
|
+ loading: false,
|
|
|
+ title: "新建调拨申请",
|
|
|
+ showModelThis: this.showModel,
|
|
|
+ ruleForm: {
|
|
|
+ supplier_code: [], //出库供应商名称
|
|
|
+ stock_code: [], //出库仓库名称
|
|
|
+ supplier_in_code: [], //入库供应商名称
|
|
|
+ stock_in_code: [], //入库仓库名称
|
|
|
+ product_go: [], //出库商品选择
|
|
|
+ product_type_code: "", //商品属性code
|
|
|
+ status: "", //审核状态
|
|
|
+ },
|
|
|
+ // tableData: [],
|
|
|
+ rulesThis: this.rules,
|
|
|
+ rules: {
|
|
|
+ supplier_code: [
|
|
|
+ {
|
|
|
+ type: "array",
|
|
|
+ required: true,
|
|
|
+ message: "请选择供应商",
|
|
|
+ trigger: "change",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ stock_code: [
|
|
|
+ {
|
|
|
+ type: "array",
|
|
|
+ required: true,
|
|
|
+ message: "请选择仓库",
|
|
|
+ trigger: "change",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ supplier_in_code: [
|
|
|
+ {
|
|
|
+ type: "array",
|
|
|
+ required: true,
|
|
|
+ message: "请选择供应商",
|
|
|
+ trigger: "change",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ stock_in_code: [
|
|
|
+ {
|
|
|
+ type: "array",
|
|
|
+ required: true,
|
|
|
+ message: "请选择仓库",
|
|
|
+ trigger: "change",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ product_go: [
|
|
|
+ {
|
|
|
+ type: "array",
|
|
|
+ required: true,
|
|
|
+ message: "请选择商品",
|
|
|
+ trigger: "change",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ columns: [
|
|
|
+ {
|
|
|
+ prop: "product_sn",
|
|
|
+ label: "商品编号",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: "product_name",
|
|
|
+ label: "商品名称",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: "product_num",
|
|
|
+ label: "总数量",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ tableData: [
|
|
|
+ {
|
|
|
+ date: "2016-05-02",
|
|
|
+ name: "王小虎",
|
|
|
+ province: "上海",
|
|
|
+ city: "普陀区",
|
|
|
+ address: "上海市普陀区金沙江路 1518 弄",
|
|
|
+ zip: 200333,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ date: "2016-05-04",
|
|
|
+ name: "王小虎",
|
|
|
+ province: "上海",
|
|
|
+ city: "普陀区",
|
|
|
+ address: "上海市普陀区金沙江路 1517 弄",
|
|
|
+ zip: 200333,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ date: "2016-05-01",
|
|
|
+ name: "王小虎",
|
|
|
+ province: "上海",
|
|
|
+ city: "普陀区",
|
|
|
+ address: "上海市普陀区金沙江路 1519 弄",
|
|
|
+ zip: 200333,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ date: "2016-05-03",
|
|
|
+ name: "王小虎",
|
|
|
+ province: "上海",
|
|
|
+ city: "普陀区",
|
|
|
+ address: "上海市普陀区金沙江路 1516 弄",
|
|
|
+ zip: 200333,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ showModel: function (val) {
|
|
|
+ this.showModelThis = val;
|
|
|
+ if (val) {
|
|
|
+ this.initForm();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ showModelThis(val) {
|
|
|
+ if (!val) {
|
|
|
+ this.$emit("cancel");
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.initForm();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 删除行操作
|
|
|
+ deleteRow(index, rows) {
|
|
|
+ // console.log(index, rows);
|
|
|
+ rows.splice(index, 1);
|
|
|
+ },
|
|
|
+ // 通知弹窗关闭
|
|
|
+ closeModel() {
|
|
|
+ this.$emit("closeModel");
|
|
|
+ },
|
|
|
+
|
|
|
+ async initForm() {
|
|
|
+ this.loading = true;
|
|
|
+ // await this.getRole();
|
|
|
+ console.log(this.id);
|
|
|
+ if (this.id === "add") {
|
|
|
+ this.rulesThis = this.rules;
|
|
|
+ await this.resetForm();
|
|
|
+ } else {
|
|
|
+ if (this.isDetail) {
|
|
|
+ this.rulesThis = {};
|
|
|
+ } else {
|
|
|
+ this.rulesThis = this.rules;
|
|
|
+ }
|
|
|
+ await this.resetForm(this.sitem);
|
|
|
+ // await this.initData()
|
|
|
+ }
|
|
|
+ this.loading = false;
|
|
|
+ },
|
|
|
+
|
|
|
+ async initData() {
|
|
|
+ const res = await asyncRequest.detail({ id: this.id });
|
|
|
+ if (res && res.code === 0 && res.data) {
|
|
|
+ this.ruleForm = res.data;
|
|
|
+ this.ruleForm.role_id = this.ruleForm.role;
|
|
|
+ } 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();
|
|
|
+ this.ruleForm = {
|
|
|
+ stock_code: [], //出库仓库编码
|
|
|
+ supplier_code: [], //出库供应商编码
|
|
|
+ supplier_in_code: [], //入库供应商编码
|
|
|
+ stock_in_code: [], //入库仓库编码
|
|
|
+ product_go: [], //出库商品
|
|
|
+ product_type_code: "", //商品属性code
|
|
|
+ status: "", //审核状态
|
|
|
+ };
|
|
|
+ if (this.id === "add" || this.isDetail) {
|
|
|
+ // this.rules.username[0].required = false;
|
|
|
+ console.log("当前是add或者 this.isDetail是true");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ async submitForm() {
|
|
|
+ await this.$refs.ruleForm.validate(async (valid) => {
|
|
|
+ if (valid) {
|
|
|
+ this.loading = true;
|
|
|
+ // const { username, name, mobile, email, role_id, status } = JSON.parse(
|
|
|
+ // JSON.stringify(this.ruleForm)
|
|
|
+ // );
|
|
|
+
|
|
|
+ const { stock_code, stock_in_code, supplier_code, supplier_in_code } =
|
|
|
+ JSON.parse(JSON.stringify(this.ruleForm));
|
|
|
+ console.log(
|
|
|
+ stock_code,
|
|
|
+ stock_in_code,
|
|
|
+ supplier_code,
|
|
|
+ supplier_in_code,
|
|
|
+ );
|
|
|
+ console.log(this.ruleForm);
|
|
|
+ const model = {
|
|
|
+ id: this.id,
|
|
|
+ wsm_out: stock_code.toString(), //出库仓库
|
|
|
+ wsm_in: stock_in_code.toString(), //入库仓库
|
|
|
+ supplier_code: supplier_code.toString(),
|
|
|
+ supplier_in_code: supplier_in_code.toString(),
|
|
|
+ status: "",
|
|
|
+ good: [
|
|
|
+ {
|
|
|
+ good_code: "df12fa1",
|
|
|
+ allot_num: 100,
|
|
|
+ type_code: "fafa131",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+ let res = {};
|
|
|
+ if (this.id === "add") {
|
|
|
+ delete model["id"];
|
|
|
+ res = await asyncRequest.add(model);
|
|
|
+ } else {
|
|
|
+ res = await asyncRequest.update(model);
|
|
|
+ }
|
|
|
+ this.loading = false;
|
|
|
+ if (res && res.code === 0) {
|
|
|
+ const title = this.id === "add" ? "添加成功" : "修改成功";
|
|
|
+ this.$notify.success({
|
|
|
+ title,
|
|
|
+ message: "",
|
|
|
+ });
|
|
|
+ this.showModelThis = false;
|
|
|
+ // 刷新
|
|
|
+ this.$emit("refresh");
|
|
|
+ } else if (res && res.code >= 100 && res.code <= 104) {
|
|
|
+ await this.logout();
|
|
|
+ } else {
|
|
|
+ this.$message.warning(res.message);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ console.log("error submit!!");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ // 执行点击商品名称的抛出事件
|
|
|
+ addGoodsRes(e) {
|
|
|
+ console.log(e);
|
|
|
+
|
|
|
+ let { good_code, good_name, type_code } = e[0];
|
|
|
+ // this.ruleForm.goods_name = good_name;
|
|
|
+ // this.ruleForm.good_type_code = type_code;
|
|
|
+ // this.ruleForm.good_code = good_code;
|
|
|
+ // this.$refs.ruleForm.validateField("goods_name");
|
|
|
+ },
|
|
|
+
|
|
|
+ // 选择出库仓库
|
|
|
+ selectStock(e) {
|
|
|
+ if (e && e.id) {
|
|
|
+ this.ruleForm.stock_code = [e.code];
|
|
|
+ this.stockCode = e.code;
|
|
|
+ if (this.stockCode == this.stock_in_code) {
|
|
|
+ this.$message({
|
|
|
+ message: "出库供应商仓库不能和入库供应商仓库相同",
|
|
|
+ type: "warning",
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.ruleForm.stockCode = [];
|
|
|
+ this.stockCode = "";
|
|
|
+ }
|
|
|
+ this.$refs.ruleForm.validateField("stock_code");
|
|
|
+ },
|
|
|
+ // 选择出库供应商
|
|
|
+ selectSupplier(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.$refs.ruleForm.validateField("supplier_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 = "";
|
|
|
+ }
|
|
|
+ this.$refs.ruleForm.validateField("stock_in_code");
|
|
|
+ },
|
|
|
+ // 选择入库供应商
|
|
|
+ selectSupplierIn(e) {
|
|
|
+ if (e && e.id) {
|
|
|
+ this.ruleForm.supplier_in_code = [e.code];
|
|
|
+ this.stock_in_code = e.code;
|
|
|
+ this.isDisabledIn = false;
|
|
|
+ } else {
|
|
|
+ this.ruleForm.supplier_in_code = [];
|
|
|
+ this.stock_in_code = "";
|
|
|
+ }
|
|
|
+ this.$refs.ruleForm.validateField("supplier_in_code");
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+ <style lang="scss" scoped>
|
|
|
+.allot {
|
|
|
+}
|
|
|
+</style>
|
|
|
+
|