Forráskód Böngészése

仓储配置页面

lxf 2 éve
szülő
commit
4d996f4c7d

+ 2 - 1
src/views/purchase-sales/inbound-outbound/manualInbound/add.vue

@@ -9,6 +9,7 @@
 import { ref, reactive, getCurrentInstance, onMounted } from "vue";
 import { showSuccessToast, showFailToast } from "vant";
 import { useRoute } from "vue-router";
+import testForm from "@/components/testForm/index.vue";
 
 const proxy = getCurrentInstance().proxy;
 const route = useRoute();
@@ -111,8 +112,8 @@ const onSubmit = () => {
   if (!formData.data.list.length > 0) return showFailToast("请添加明细!");
   proxy.post("/stock/add", formData.data).then(
     () => {
+      showSuccessToast("入库成功");
       setTimeout(() => {
-        showSuccessToast("入库成功");
         onClickLeft();
         // proxy.$router.push("/main/manualInbound");
       }, 500);

+ 2 - 2
src/views/purchase-sales/inbound-outbound/manualOutbound/add.vue

@@ -9,6 +9,7 @@
 import { ref, reactive, getCurrentInstance, onMounted } from "vue";
 import { showSuccessToast, showFailToast } from "vant";
 import { useRoute } from "vue-router";
+import testForm from "@/components/testForm/index.vue";
 
 const proxy = getCurrentInstance().proxy;
 const route = useRoute();
@@ -111,10 +112,9 @@ const onSubmit = () => {
   if (!formData.data.list.length > 0) return showFailToast("请添加明细!");
   proxy.post("/stock/edit", formData.data).then(
     () => {
+      showSuccessToast("出库成功");
       setTimeout(() => {
-        showSuccessToast("出库成功");
         onClickLeft();
-        // proxy.$router.push("/main/manualInbound");
       }, 500);
     },
     (err) => {

+ 82 - 163
src/views/warehouse/warehouseConfig/add.vue

@@ -1,184 +1,103 @@
 <template>
   <div class="form">
-    <van-nav-bar
-      title="仓库维护"
-      left-text="返回"
-      left-arrow
-      @click-left="onClickLeft"
-    >
-    </van-nav-bar>
-    <van-form @submit="onSubmit" label-align="top" style="margin-top: 20px">
-      <van-cell-group inset>
-        <van-field
-          v-model="formData.typeName"
-          is-link
-          readonly
-          label="仓库类型"
-          placeholder="选择仓库类型"
-          @click="typeModal = true"
-          :rules="[{ required: true, message: '仓库类型不能为空' }]"
-          required
-        />
-        <van-popup v-model:show="typeModal" round position="bottom">
-          <van-picker
-            :columns="columns"
-            @cancel="typeModal = false"
-            @confirm="onConfirm"
-          />
-        </van-popup>
-        <van-field
-          v-model="formData.keeperName"
-          is-link
-          readonly
-          label="仓库管理员"
-          placeholder="选择仓库管理员"
-          @click="keeper = true"
-        />
-        <van-popup v-model:show="keeper" round position="bottom">
-          <van-picker
-            :columns="keeperColumns"
-            @cancel="keeper = false"
-            @confirm="onConfirmKeeper"
-          />
-        </van-popup>
-        <van-field
-          v-model="formData.name"
-          name="仓库名称"
-          label="仓库名称"
-          placeholder="请填写仓库名称"
-          :rules="[{ required: true, message: '仓库名称不能为空' }]"
-          required
-        />
-        <van-field
-          v-model="formData.remark"
-          rows="3"
-          type="textarea"
-          name="备注"
-          label="备注"
-          placeholder="请填写备注"
-        />
-      </van-cell-group>
-      <div style="margin: 16px">
-        <van-button round block type="primary" native-type="submit">
-          提交
-        </van-button>
-      </div>
-    </van-form>
+    <van-nav-bar title="仓库维护" left-text="返回" left-arrow @click-left="onClickLeft"> </van-nav-bar>
+    <testForm v-model="formData.data" :formOption="formOption" :formConfig="formConfig" :rules="rules" @onSubmit="onSubmit" ref="formDom"></testForm>
   </div>
 </template>
 
-
-
 <script setup>
-import { ref, getCurrentInstance, onMounted } from "vue";
-import {
-  showSuccessToast,
-  showFailToast,
-  showDialog,
-  showConfirmDialog,
-} from "vant";
+import { ref, reactive, getCurrentInstance, onMounted } from "vue";
+import { showSuccessToast } from "vant";
 import { useRoute } from "vue-router";
 import { getUserInfo } from "@/utils/auth";
+import testForm from "@/components/testForm/index.vue";
+
 const proxy = getCurrentInstance().proxy;
 const route = useRoute();
-const showPicker = ref(false);
-const typeModal = ref(false);
-
-const formData = ref({
-  name: null,
-  type: null,
-  typeName: null,
-  remark: null,
+const formDom = ref(null);
+const formData = reactive({
+  data: {
+    type: "",
+    keeperId: "",
+    name: "",
+    remark: "",
+  },
 });
-const keeper = ref(false);
-const keeperColumns = ref([]);
-
-const getUserList = () => {
-  proxy.get("/tenantUser/list?pageNum=1&pageSize=10000").then((res) => {
-    keeperColumns.value = res.rows.map((item) => {
-      return {
-        text: item.nickName,
-        value: item.userId,
-      };
-    });
-    console.log(keeperColumns);
-    //formData.value.keeperName = formData.value.keeper ?  keeperColumns.value.find(item => item.value == formData.value.keeper).text : null
-  });
-};
-
-const getDict = () => {
-  proxy
-    .post("/dictTenantData/page", {
-      pageNum: 1,
-      pageSize: 999,
-      tenantId: getUserInfo().tenantId,
-      dictCode: "warehouse_type",
-    })
-    .then((res) => {
-      console.log(res, 12312312);
-      columns.value = res.data.rows.map((item) => {
-        return {
-          text: item.dictValue,
-          value: item.dictKey,
-        };
-      });
-      formData.value.typeName =
-        formData.value.type || formData.value.type === 0
-          ? columns.value.find((item) => item.value == formData.value.type).text
-          : null;
-    });
-};
-
-const columns = ref([]);
-
-const onConfirmKeeper = ({ selectedOptions }) => {
-  formData.value.keeperId = selectedOptions[0].value;
-  formData.value.keeperName = selectedOptions[0].text;
-  keeper.value = false;
+const rules = {
+  type: [{ required: true, message: "仓库类型不能为空" }],
+  name: [{ required: true, message: "仓库名称不能为空" }],
 };
-
-const onConfirm = ({ selectedOptions }) => {
-  formData.value.type = selectedOptions[0].value;
-  formData.value.typeName = selectedOptions[0].text;
-  typeModal.value = false;
-};
-
-const onClickLeft = () => history.back();
-
-const warehouseDelete = () => {
-  showConfirmDialog({
-    title: "提示",
-    message: "您确定删除本条数据吗?",
-  }).then(() => {
-    proxy.post("/warehouse/delete", { id: route.query.id }).then((res) => {
-      setTimeout(() => {
-        showSuccessToast("删除成功");
-        proxy.$router.push("/main/warehouseConfig");
-      }, 500);
-    });
+const formOption = reactive({
+  readonly: false, //用于控制整个表单是否只读
+  disabled: false,
+  labelAlign: "top",
+  scroll: true,
+  labelWidth: "62pk",
+});
+const formConfig = reactive([
+  {
+    type: "picker",
+    label: "仓库类型",
+    prop: "type",
+    itemType: "onePicker",
+    showPicker: false,
+    fieldNames: {
+      text: "dictValue",
+      value: "dictKey",
+    },
+    data: [],
+  },
+  {
+    type: "picker",
+    label: "仓库管理员",
+    prop: "keeperId",
+    itemType: "onePicker",
+    showPicker: false,
+    fieldNames: {
+      text: "nickName",
+      value: "userId",
+    },
+    data: [],
+  },
+  {
+    type: "input",
+    itemType: "text",
+    label: "仓库名称",
+    prop: "name",
+    clearable: true,
+  },
+  {
+    type: "input",
+    itemType: "textarea",
+    label: "备注",
+    prop: "remark",
+    clearable: true,
+  },
+]);
+const getDict = async () => {
+  await proxy.post("/dictTenantData/page", { pageNum: 1, pageSize: 999, tenantId: getUserInfo().tenantId, dictCode: "warehouse_type" }).then((res) => {
+    formConfig[0].data = res.data.rows;
+  });
+  await proxy.get("/tenantUser/list", { pageNum: 1, pageSize: 10000, tenantId: getUserInfo().tenantId }).then((res) => {
+    formConfig[1].data = res.rows;
   });
 };
-
+const onClickLeft = () => history.back();
 const onSubmit = () => {
-  proxy
-    .post("/warehouse/" + (!route.query.id ? "add" : "edit"), formData.value)
-    .then((res) => {
-      setTimeout(() => {
-        showSuccessToast(!route.query.id ? "添加成功" : "编辑成功");
-        proxy.$router.push("/main/warehouseConfig");
-      }, 500);
-    });
+  proxy.post("/warehouse/" + (!route.query.id ? "add" : "edit"), formData.data).then(() => {
+    showSuccessToast(!route.query.id ? "添加成功" : "编辑成功");
+    setTimeout(() => {
+      onClickLeft();
+    }, 500);
+  });
 };
-onMounted(() => {
+onMounted(async () => {
+  await getDict();
   if (route.query.id) {
+    console.log(route.query.id);
     proxy.post("/warehouse/detail", { id: route.query.id }).then((res) => {
-      formData.value = res.data;
-      getUserList();
-      getDict();
+      formData.data = res.data;
     });
-  } else {
-    getUserList();
-    getDict();
   }
 });
-</script>
+</script>