cz 1 anno fa
parent
commit
27804fe7bb

+ 30 - 14
src/components/testForm/index.vue

@@ -58,12 +58,20 @@
                      v-model="formData[i.prop + 'Name']" is-link :readonly="true" :placeholder="i.placeholder ? i.placeholder : '请选择'"
                      @click="() => (!formOption.readonly ? (i.showPicker = true) : '')" :rules="getRules(i)" :required="getRequired(i)">
           </van-field>
-          <van-popup v-model:show="i.showPicker" round position="bottom" :style="{ height: '40%' }"
+          <van-popup v-model:show="i.showPicker" round position="bottom" :style="{ height: '60%' }"
                      v-if="i.type == 'multipleChoice' && i.itemType == 'multiple'">
-            <van-checkbox-group v-model="formData[i.prop]" @change="changeCheckboxGroup(formData, i.prop, i.data, i.fieldNames)"
-                                class="multipleChoice">
-              <van-checkbox v-for="item in i.data" :key="item.value" :name="item.value">{{ item.text }}</van-checkbox>
-            </van-checkbox-group>
+            <div style="padding: 10px; height: calc(100% - 40px)">
+              <div style="display: flex; justify-content: space-between">
+                <van-button plain type="primary" @click="i.showPicker = false" style="border: none">关闭</van-button>
+                <van-button plain type="primary" style="border: none" @click="i.showPicker = false">确定</van-button>
+              </div>
+              <div style="height: calc(100% - 30px); overflow: auto">
+                <van-checkbox-group v-model="formData[i.prop]" @change="changeCheckboxGroup(formData, i.prop, i.data, i.fieldNames)">
+                  <van-checkbox v-for="item in i.data" :key="item.value" :name="item.value" style="margin-top: 5px">{{ item.text }}</van-checkbox>
+                </van-checkbox-group>
+              </div>
+            </div>
+
           </van-popup>
           <!-- 时间选择器 -->
           <van-field v-if="i.type == 'picker' && i.itemType == 'datePicker'" :label="i.label" :name="i.prop" v-model="formData[i.prop]" is-link
@@ -758,13 +766,16 @@ watch(
   }
 );
 const changeCheckboxGroup = (form, label, data, fieldNames) => {
+  if (!Array.isArray(form[label])) {
+    return;
+  }
   let text = "";
   if (form[label] && form[label].length > 0) {
     form[label].map((item) => {
       let list = data.filter((itemData) => itemData[fieldNames.value] === item);
       if (list && list.length > 0) {
         if (text) {
-          text = text + "," + list[0][fieldNames.text];
+          text = text + "" + list[0][fieldNames.text];
         } else {
           text = list[0][fieldNames.text];
         }
@@ -781,14 +792,19 @@ const datePickerTimeConfirm = (item, index) => {
   formConfig.value[index].showPicker = false;
 };
 const defaultTimeFn = (item, index) => {
-  datePickerDateArr.value = formatDate(
-    new Date(formData.value[item.prop]),
-    "yyyy-MM-dd"
-  ).split("-");
-  datePickerTimeArr.value = formatDate(
-    new Date(formData.value[item.prop]),
-    "hh:mm:ss"
-  ).split(":");
+  if (formData.value[item.prop]) {
+    datePickerDateArr.value = formatDate(
+      new Date(formData.value[item.prop]),
+      "yyyy-MM-dd"
+    ).split("-");
+    datePickerTimeArr.value = formatDate(
+      new Date(formData.value[item.prop]),
+      "hh:mm:ss"
+    ).split(":");
+  } else {
+    datePickerDateArr.value = formatDate(new Date(), "yyyy-MM-dd").split("-");
+    datePickerTimeArr.value = formatDate(new Date(), "hh:mm:ss").split(":");
+  }
   formConfig.value[index].showPicker = true;
 };
 const validateForm = async () => {

+ 10 - 0
src/router/index.js

@@ -448,6 +448,16 @@ const routes = [{
 				component: () => import('../views/MES/productionReport/add.vue')
 			},
 			{
+				path: 'supplementaryOrder',
+				name: '报损管理',
+				component: () => import('../views/MES/supplementaryOrder/index.vue')
+			},
+			{
+				path: 'supplementaryOrderAdd',
+				name: '报损添加',
+				component: () => import('../views/MES/supplementaryOrder/add.vue')
+			},
+			{
 				path: 'reportDetail',
 				name: '报工明细',
 				component: () => import('../views/MES/reportDetail/index.vue')

+ 255 - 0
src/views/MES/supplementaryOrder/add.vue

@@ -0,0 +1,255 @@
+<template>
+  <div class="form">
+    <van-nav-bar :title="'报损管理'" :left-text="$t('common.back')" 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, reactive } from "vue";
+import { showSuccessToast, showToast, showFailToast } 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 show = ref(false);
+const typeModal = ref(false);
+const unitModal = ref(false);
+const classification = ref([]);
+const formData = reactive({
+  data: {
+    prodOrderId: "",
+    respUserSet: [],
+  },
+});
+const formDom = ref(null);
+const formOption = reactive({
+  readonly: false, //用于控制整个表单是否只读
+  disabled: false,
+  labelAlign: "top",
+  scroll: true,
+  labelWidth: "62pk",
+  hiddenSubmitBtn: false,
+});
+const formConfig = reactive([
+  {
+    type: "picker",
+    label: "类型",
+    prop: "type",
+    itemType: "onePicker",
+    showPicker: false,
+    fieldNames: {
+      text: "label",
+      value: "value",
+    },
+    data: [
+      {
+        label: "补单",
+        value: 1,
+      },
+      {
+        label: "丢失",
+        value: 2,
+      },
+    ],
+  },
+  {
+    type: "picker",
+    label: "发起时间",
+    prop: "repoTime",
+    itemType: "datePickerTime",
+    needDefault: true,
+    showPicker: false,
+  },
+  {
+    type: "multipleChoice",
+    itemType: "multiple",
+    prop: "respUserSet",
+    label: "责任人",
+    showPicker: false,
+    fieldNames: {
+      text: "text",
+      value: "value",
+    },
+    data: [],
+  },
+  {
+    type: "picker",
+    label: "生产订单",
+    prop: "prodOrderId",
+    itemType: "onePicker",
+    showPicker: false,
+    fieldNames: {
+      text: "label",
+      value: "value",
+    },
+    data: [],
+    changeFn: (val, data) => {
+      proxy.formChange(val, data, formData);
+      if (val.selectedValues[0]) {
+        let current = data.data.find((x) => x.value == val.selectedValues[0]);
+        if (current) {
+          proxy
+            .post("/contractProductBom/getList", {
+              contractId: current.contractId,
+            })
+            .then((res) => {
+              formConfig[4].data = res.data.map((x) => ({
+                ...x,
+                label: x.productName,
+                value: x.materialId,
+              }));
+            });
+        }
+      }
+      data.showPicker = false;
+    },
+  },
+  {
+    type: "picker",
+    label: "物品名称",
+    prop: "materialId",
+    itemType: "onePicker",
+    showPicker: false,
+    fieldNames: {
+      text: "label",
+      value: "value",
+    },
+    data: [],
+    changeFn: (val, data) => {
+      proxy.formChange(val, data, formData);
+      if (val.selectedValues[0]) {
+        let current = data.data.find((x) => x.value == val.selectedValues[0]);
+        if (current) {
+          formData.data.productCode = current.productCode;
+          formData.data.productQuantity = current.quantity;
+        }
+      }
+      data.showPicker = false;
+    },
+  },
+  {
+    type: "input",
+    itemType: "text",
+    label: "物品编码",
+    prop: "productCode",
+    readonly: true,
+  },
+  {
+    type: "input",
+    itemType: "text",
+    label: "物品数量",
+    prop: "productQuantity",
+    readonly: true,
+  },
+  {
+    type: "input",
+    label: "数量",
+    prop: "quantity",
+    itemType: "digit",
+  },
+  {
+    type: "input",
+    itemType: "textarea",
+    label: "备注",
+    prop: "remark",
+  },
+]);
+const rules = {
+  type: [{ required: true, message: "请选择类型" }],
+  repoTime: [{ required: true, message: "请选择发起时间" }],
+  respUserSet: [{ required: true, message: "请选择责任人" }],
+  prodOrderId: [{ required: true, message: "请选择生产订单" }],
+  materialId: [{ required: true, message: "请选择物品名称" }],
+  quantity: [{ required: true, message: "请输入数量" }],
+  remark: [{ required: true, message: "请输入备注" }],
+};
+const userList = ref([]);
+const prodOrderList = ref([]);
+const getDict = () => {
+  proxy
+    .get("/tenantUser/list", {
+      pageNum: 1,
+      pageSize: 9999,
+      keyword: "",
+      tenantId: getUserInfo().tenantId,
+      companyId: getUserInfo().companyId,
+    })
+    .then((res) => {
+      formConfig[2].data = res.rows.map((item) => {
+        return {
+          text: item.nickName,
+          value: item.userId,
+        };
+      });
+    });
+
+  proxy
+    .post("produceOrder/page", {
+      pageNum: 1,
+      pageSize: 9999,
+      produceStatus: "0,1",
+    })
+    .then((res) => {
+      prodOrderList.value = res.data.rows.map((x) => ({
+        ...x,
+        label: x.code,
+        value: x.id,
+      }));
+      formConfig[3].data = prodOrderList.value;
+    });
+};
+getDict();
+
+const getDetail = () => {
+  proxy
+    .post("/reportLossesDetails/detail", {
+      id: route.query.id,
+    })
+    .then(
+      (res) => {
+        formData.data = res.data;
+        formData.data.respUserSet = res.data.respUserSet.split(",");
+        setTimeout(() => {
+          formDom.value.formDataShowLabelOne();
+        }, 200);
+      },
+      (err) => {
+        setTimeout(() => {
+          onClickLeft();
+        }, 1000);
+      }
+    );
+};
+
+const onClickLeft = () => history.back();
+const onSubmit = () => {
+  if (Number(formData.data.quantity) < 1) {
+    return showFailToast("数量不能为0");
+  }
+  if (Number(formData.data.quantity) > Number(formData.data.productQuantity)) {
+    return showFailToast("数量不可大于物品数量");
+  }
+  formData.data.respUserSet = formData.data.respUserSet.join(",");
+  proxy.post("/reportLossesDetails/add", formData.data).then(() => {
+    showSuccessToast(proxy.t("common.addSuccess"));
+    setTimeout(() => {
+      proxy.$router.push("/main/supplementaryOrder");
+    }, 500);
+  });
+};
+
+onMounted(() => {
+  if (route.query && route.query.id) {
+    // formData.data = { ...route.query };
+    getDetail();
+    formOption.readonly = true;
+    formOption.hiddenSubmitBtn = true;
+  }
+});
+</script>

+ 122 - 0
src/views/MES/supplementaryOrder/index.vue

@@ -0,0 +1,122 @@
+<template>
+  <div style="padding-bottom: 60px">
+    <van-nav-bar :title="'报损管理'" left-text="" left-arrow @click-left="onClickLeft" @click-right="onClickRight">
+      <template #right> 添加 </template>
+    </van-nav-bar>
+    <van-search v-model="req.keyword" :placeholder="$t('common.pleaseEnterKeywords')" @search="onRefresh" />
+    <van-pull-refresh v-model="loading" @refresh="onRefresh">
+      <div class="list">
+        <van-list v-model:loading="loading" :finished="finished" :finished-text="$t('common.noMore')" @load="onLoad" style="margin-bottom: 60px">
+          <commonList :data="listData" :config="listConfig" :showMore="false"></commonList>
+          <!-- @onClick="toDtl" -->
+        </van-list>
+      </div>
+    </van-pull-refresh>
+
+  </div>
+</template>
+<script setup>
+import { ref, getCurrentInstance, onMounted, nextTick } from "vue";
+import commonList from "@/components/common-list.vue";
+import { useRoute } from "vue-router";
+const loading = ref(false);
+const router = useRoute();
+const req = ref({
+  pageNum: 1,
+  keyword: null,
+});
+const finished = ref(false);
+const proxy = getCurrentInstance().proxy;
+const listData = ref([]);
+const listConfig = ref([
+  {
+    label: "类型",
+    prop: "typeName",
+  },
+  {
+    label: "发起时间",
+    prop: "repoTime",
+  },
+  {
+    label: "责任人",
+    prop: "respUserName",
+  },
+  {
+    label: "生产订单",
+    prop: "prodOrderCode",
+  },
+  {
+    label: "物品编号",
+    prop: "materialCode",
+  },
+  {
+    label: "物品名称",
+    prop: "materialName",
+  },
+  {
+    label: "数量",
+    prop: "quantity",
+  },
+  {
+    label: "备注",
+    prop: "remark",
+  },
+]);
+const onRefresh = () => {
+  req.value.pageNum = 1;
+  finished.value = false;
+  getList("refresh");
+};
+const onLoad = () => {
+  // getList();
+};
+
+const onClickLeft = () => proxy.$router.push("/main/working");
+
+const onClickRight = () => {
+  proxy.$router.push({
+    path: "/main/supplementaryOrderAdd",
+  });
+};
+
+const toDtl = (row) => {
+  proxy.$router.push({
+    path: "/main/supplementaryOrderAdd",
+    query: {
+      ...row,
+      id: row.id,
+    },
+  });
+};
+
+const getList = (type) => {
+  loading.value = true;
+  proxy
+    .post("/reportLossesDetails/page", req.value)
+    .then((res) => {
+      res.data.rows.forEach((x) => {
+        x.typeName = x.type == 1 ? "补单" : "丢件";
+      });
+      listData.value =
+        type === "refresh"
+          ? res.data.rows
+          : listData.value.concat(res.data.rows);
+      if (req.value.pageNum * 10 >= res.data.total) {
+        finished.value = true;
+      }
+      req.value.pageNum++;
+      loading.value = false;
+    })
+    .catch((err) => {
+      loading.value = false;
+    });
+};
+
+getList();
+</script>
+
+<style lang="scss" scoped>
+.list {
+  min-height: 70vh;
+}
+</style>