Browse Source

成品仓入库登记功能

lxf 1 year ago
parent
commit
d1571bfa5b
1 changed files with 163 additions and 0 deletions
  1. 163 0
      src/views/production/warehouse/finished-parts-storage/index.vue

+ 163 - 0
src/views/production/warehouse/finished-parts-storage/index.vue

@@ -10,6 +10,12 @@
           :searchConfig="searchConfig"
           highlight-current-row
           :action-list="[
+            judgeUser()
+              ? {
+                  text: '成品仓入库登记',
+                  action: () => clickModal(),
+                }
+              : {},
             {
               text: '查看今日入库列表',
               action: () => clickViewTodayEntry(),
@@ -58,6 +64,70 @@
         <el-button @click="openTodayEntry = false">关 闭</el-button>
       </template>
     </el-dialog>
+
+    <el-dialog title="成品仓入库登记" v-if="openAdd" v-model="openAdd" width="70%">
+      <div style="max-height: calc(100vh - 176px); overflow-y: auto; overflow-x: hidden" v-loading="loadingAdd">
+        <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
+          <template #basicInformation>
+            <div style="width: 100%">
+              <el-row>
+                <el-col :span="12">
+                  <el-form-item label="事业部" prop="departmentId" style="width: 100%; margin-bottom: 18px">
+                    <el-select v-model="formData.data.departmentId" placeholder="请选择调事业部" clearable style="width: 100%">
+                      <el-option v-for="item in departmentList" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
+                    </el-select>
+                  </el-form-item>
+                  <el-form-item label="备注" prop="remark" style="width: 100%; margin-bottom: 18px">
+                    <el-input v-model="formData.data.remark" :rows="4" type="textarea" placeholder="请输入备注" />
+                  </el-form-item>
+                </el-col>
+              </el-row>
+            </div>
+          </template>
+          <template #skuList>
+            <div style="width: 100%; padding: 0 20px">
+              <div style="margin-bottom: 10px">
+                <el-button type="primary" size="small" @click="clickAddSKU()">选择SKU</el-button>
+              </div>
+              <el-table :data="formData.data.skuList" :row-style="{ height: '35px' }" header-row-class-name="tableHeader">
+                <el-table-column label="品号" prop="skuSpecCode" width="160" />
+                <el-table-column label="品名" prop="skuSpecName" min-width="220" />
+                <el-table-column label="入库数量" width="160">
+                  <template #default="{ row, $index }">
+                    <el-form-item :prop="'skuList.' + $index + '.quantity'" :rules="rules.quantity" :inline-message="true" style="width: 100%">
+                      <el-input-number
+                        onmousewheel="return false;"
+                        v-model="row.quantity"
+                        placeholder="入库数量"
+                        style="width: 100%"
+                        :controls="false"
+                        :min="0"
+                        :precision="0" />
+                    </el-form-item>
+                  </template>
+                </el-table-column>
+                <el-table-column label="操作" align="center" fixed="right" width="60">
+                  <template #default="{ $index }">
+                    <el-button type="danger" @click="clickDelete($index)" text>删除</el-button>
+                  </template>
+                </el-table-column>
+              </el-table>
+            </div>
+          </template>
+        </byForm>
+      </div>
+      <div style="text-align: center; margin: 10px">
+        <el-button @click="openAdd = false" size="large">取 消</el-button>
+        <el-button type="primary" @click="submitForm()" size="large" v-preReClick>确 定</el-button>
+      </div>
+    </el-dialog>
+
+    <el-dialog title="选择产品" v-if="openProduct" v-model="openProduct" width="90%">
+      <SelectProduct :selectStatus="true" :type="'null'" @selectProduct="selectProduct"></SelectProduct>
+      <template #footer>
+        <el-button @click="openProduct = false" size="large">关 闭</el-button>
+      </template>
+    </el-dialog>
   </el-card>
 </template>
 
@@ -65,6 +135,8 @@
 import byTable from "/src/components/byTable/index";
 import { ElMessage } from "element-plus";
 import moment from "moment";
+import byForm from "/src/components/byForm/index";
+import SelectProduct from "/src/views/group/product/management/index";
 
 const { proxy } = getCurrentInstance();
 const activeName = ref("first");
@@ -341,6 +413,97 @@ const clickViewTodayEntry = () => {
     }, 200);
   });
 };
+const judgeUser = () => {
+  return proxy.useUserStore().user.userId === "1";
+};
+const openAdd = ref(false);
+const loadingAdd = ref(false);
+const formData = reactive({
+  data: {
+    departmentId: "",
+    remark: "",
+    skuList: [],
+  },
+});
+const formOption = reactive({
+  inline: true,
+  labelWidth: "100px",
+  itemWidth: 100,
+  rules: [],
+  labelPosition: "right",
+});
+const formConfig = computed(() => {
+  return [
+    {
+      type: "slot",
+      slotName: "basicInformation",
+      label: "",
+    },
+    {
+      type: "slot",
+      slotName: "skuList",
+      label: "",
+    },
+  ];
+});
+const rules = ref({
+  departmentId: [{ required: true, message: "请选择事业部", trigger: "change" }],
+  quantity: [{ required: true, message: "请输入数量", trigger: "blur" }],
+});
+const clickModal = () => {
+  formData.data = {
+    departmentId: "0",
+    remark: "",
+    skuList: [],
+  };
+  loadingAdd.value = false;
+  openAdd.value = true;
+};
+const clickDelete = (index) => {
+  formData.data.skuList.splice(index, 1);
+};
+const openProduct = ref(false);
+const clickAddSKU = () => {
+  openProduct.value = true;
+};
+const selectProduct = (row) => {
+  if (row.id) {
+    let list = formData.data.skuList.filter((item) => item.skuSpecId === row.id);
+    if (list && list.length > 0) {
+      return ElMessage("该产品已添加");
+    }
+    formData.data.skuList.push({
+      skuSpecCode: row.code,
+      skuSpecName: row.name,
+      skuSpecId: row.id,
+      quantity: undefined,
+    });
+    ElMessage({ message: "添加成功", type: "success" });
+  } else {
+    ElMessage("添加失败");
+  }
+};
+const submit = ref(null);
+const submitForm = () => {
+  submit.value.handleSubmit(() => {
+    if (formData.data.skuList && formData.data.skuList.length > 0) {
+      loadingAdd.value = true;
+      proxy.post("/inventoryFinished/inStorageAdd", formData.data).then(
+        () => {
+          ElMessage({ message: "提交成功", type: "success" });
+          openAdd.value = false;
+          getList();
+        },
+        (err) => {
+          console.log(err);
+          loadingAdd.value = false;
+        }
+      );
+    } else {
+      return ElMessage("请添加SKU");
+    }
+  });
+};
 </script>
 
 <style lang="scss" scoped>