Kaynağa Gözat

jxst新需求

cz 1 yıl önce
ebeveyn
işleme
02fe5d4941

+ 7 - 9
src/components/common-list.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="common-list">
-    <ul style="border-top:52px solid #f2f2f2">
+    <ul style="border-top: 2px solid #f2f2f2">
       <li v-for="i in listData" :key="i.id">
         <div class="left-box" style="margin-right: 20px" v-if="isCheckbox">
           <van-checkbox
@@ -11,25 +11,23 @@
             :disabled="optionalValue ? optionalValue != i[optionalKey] : false"
           ></van-checkbox>
         </div>
-        <p>
-          
-        </p>
+        <p></p>
         <div
           class="center-content"
           style="line-height: 24px"
           @click="listCk(i)"
         >
           <div v-for="j in config" :key="j.prop" style="display: flex">
-            <span style="width:100px;">{{ j.label }}:</span>
-            <span v-if="j.type && j.type === 'slot'" style="flex: 1;">
+            <span style="width: 100px">{{ j.label }}:</span>
+            <span v-if="j.type && j.type === 'slot'" style="flex: 1">
               <slot :name="j.slotName" :row="i">
                 {{ j.slotName }}插槽占位符
               </slot>
             </span>
-            <span v-else  style="flex: 1;">
-              {{ i[j.prop] || ''}}
+            <span v-else style="flex: 1">
+              {{ i[j.prop] || "" }}
             </span>
-          </div> 
+          </div>
         </div>
         <div class="more-box" v-if="showMore" @click="listCk(i)">
           <van-icon name="arrow" />

+ 163 - 37
src/views/JXSK/mes/task/add.vue

@@ -14,7 +14,66 @@
       :rules="rules"
       @onSubmit="onSubmit"
       ref="formDom"
-    ></testForm>
+    >
+      <template
+        v-for="(cur, index) in productionProcessesList"
+        :key="cur.id"
+        v-slot:[cur.id]="{ item }"
+      >
+        <div style="width: 100%; display: flex">
+          <div style="width: calc(100vw - 100px)">{{ cur.currentUser }}</div>
+          <div style="width: 100px; float: right; margin-top: -20px">
+            <van-button
+              plain
+              type="primary"
+              @click="cur.showPicker = true"
+              style="border: none"
+              >选择</van-button
+            >
+          </div>
+        </div>
+        <van-popup
+          v-model:show="cur.showPicker"
+          round
+          position="bottom"
+          :style="{ height: '60%' }"
+        >
+          <div style="padding: 10px; height: calc(100% - 40px)">
+            <div style="display: flex; justify-content: space-between">
+              <van-button
+                plain
+                type="primary"
+                @click="cur.showPicker = false"
+                style="border: none"
+                >关闭</van-button
+              >
+              <van-button
+                plain
+                type="primary"
+                style="border: none"
+                @click="cur.showPicker = false"
+                >确定</van-button
+              >
+            </div>
+            <div style="height: calc(100% - 30px); overflow: auto">
+              <van-checkbox-group
+                v-model="productionObj[cur.id]"
+                @change="(val) => handleSelectPeople(val, index)"
+              >
+                <van-checkbox
+                  :name="item.value"
+                  v-for="(item, index) in userList"
+                  :key="item.value"
+                  style="margin-top: 5px"
+                >
+                  {{ item.label }}</van-checkbox
+                >
+              </van-checkbox-group>
+            </div>
+          </div>
+        </van-popup>
+      </template>
+    </testForm>
   </div>
 </template>
 
@@ -23,6 +82,8 @@ import { ref, reactive, getCurrentInstance, onMounted } from "vue";
 import { showSuccessToast, showFailToast } from "vant";
 import { useRoute } from "vue-router";
 import testForm from "@/components/testForm/index.vue";
+import { getUserInfo } from "@/utils/auth";
+
 const proxy = getCurrentInstance().proxy;
 const route = useRoute();
 const formDom = ref(null);
@@ -32,10 +93,18 @@ const formData = reactive({
   },
 });
 const rules = {
-  productionPlanId: [{ required: true, message: proxy.t('task.selectProductionPlan') }],
-  dueDate: [{ required: true, message: proxy.t('task.selectCompletionDeadline') }],
-  personLiableId: [{ required: true, message: proxy.t('task.selectPrincipal') }],
-  quantity: [{ required: true, message: proxy.t('task.taskQuantityCanNotBeEmpty') }],
+  productionPlanId: [
+    { required: true, message: proxy.t("task.selectProductionPlan") },
+  ],
+  dueDate: [
+    { required: true, message: proxy.t("task.selectCompletionDeadline") },
+  ],
+  personLiableId: [
+    { required: true, message: proxy.t("task.selectPrincipal") },
+  ],
+  quantity: [
+    { required: true, message: proxy.t("task.taskQuantityCanNotBeEmpty") },
+  ],
 };
 const formOption = reactive({
   readonly: false, //用于控制整个表单是否只读
@@ -48,26 +117,26 @@ const formOption = reactive({
     isNeed: false,
     prop: "productionTaskDetailList",
     plain: true,
-    listTitle: proxy.t('common.productDetails'),
+    listTitle: proxy.t("common.productDetails"),
     listConfig: [
       {
         type: "input",
         itemType: "text",
-        label: proxy.t('receive.productSN'),
+        label: proxy.t("receive.productSN"),
         prop: "productSn",
         readonly: true,
       },
       {
         type: "input",
         itemType: "text",
-        label: proxy.t('task.currentProcess'),
+        label: proxy.t("task.currentProcess"),
         prop: "productionProcessesName",
         readonly: true,
       },
       {
         type: "input",
         itemType: "text",
-        label: proxy.t('task.accumulatedTimeConsumption'),
+        label: proxy.t("task.accumulatedTimeConsumption"),
         prop: "cumulativeTime",
         readonly: true,
       },
@@ -78,7 +147,7 @@ const formOption = reactive({
 const formConfig = reactive([
   {
     type: "picker",
-    label: proxy.t('task.productionPlan'),
+    label: proxy.t("task.productionPlan"),
     prop: "productionPlanId",
     itemType: "onePicker",
     showPicker: false,
@@ -100,43 +169,44 @@ const formConfig = reactive([
       } else {
         formConfig[index].showPicker = false;
       }
+      getProductionDetails(formData.data.productionPlanId);
     },
   },
   {
     type: "input",
     itemType: "text",
-    label: proxy.t('task.productName'),
+    label: proxy.t("task.productName"),
     prop: "productName",
     readonly: true,
   },
   {
     type: "input",
     itemType: "number",
-    label: proxy.t('task.scheduledQuantity'),
+    label: proxy.t("task.scheduledQuantity"),
     prop: "waitQuantity",
     readonly: true,
   },
   {
     type: "input",
     itemType: "number",
-    label: proxy.t('task.taskQuantity'),
+    label: proxy.t("task.taskQuantity"),
     prop: "quantity",
   },
+  // {
+  //   type: "picker",
+  //   label: proxy.t("task.principal"),
+  //   prop: "personLiableId",
+  //   itemType: "onePicker",
+  //   showPicker: false,
+  //   fieldNames: {
+  //     text: "label",
+  //     value: "value",
+  //   },
+  //   data: [],
+  // },
   {
     type: "picker",
-    label: proxy.t('task.principal'),
-    prop: "personLiableId",
-    itemType: "onePicker",
-    showPicker: false,
-    fieldNames: {
-      text: "label",
-      value: "value",
-    },
-    data: [],
-  },
-  {
-    type: "picker",
-    label: proxy.t('task.completionDeadline'),
+    label: proxy.t("task.completionDeadline"),
     prop: "dueDate",
     itemType: "datePicker",
     showPicker: false,
@@ -144,9 +214,14 @@ const formConfig = reactive([
     columnsType: ["year", "month", "day"],
   },
 ]);
+const userList = ref([]);
 const getDict = () => {
   proxy
-    .post("/productionPlan/page", { pageNum: 1, pageSize: 9999 })
+    .post("/productionPlan/page", {
+      pageNum: 1,
+      pageSize: 9999,
+      isRemaining: "1",
+    })
     .then((res) => {
       formConfig[0].data = res.data.rows.map((item) => {
         return {
@@ -157,28 +232,48 @@ const getDict = () => {
       });
     });
 
-  proxy.get("/system/user/list?pageNum=1&pageSize=9999").then((res) => {
-    formConfig[4].data = res.rows.map((item) => {
-      return {
-        label: item.userName,
-        value: item.userId,
-      };
+  proxy
+    .get("/tenantUser/list", {
+      pageNum: 1,
+      pageSize: 10000,
+      tenantId: getUserInfo().tenantId,
+    })
+    .then((res) => {
+      if (res.rows && res.rows.length > 0) {
+        userList.value = res.rows.map((item) => {
+          return {
+            label: item.nickName,
+            value: item.userId,
+          };
+        });
+        // formConfig[4].data = userList.value;
+      }
     });
-  });
 };
 
 const onClickLeft = () => history.back();
 const onSubmit = () => {
   if (Number(formData.data.quantity) > Number(formData.data.waitQuantity)) {
-    return showFailToast(proxy.t('task.taskQuantityCanNotBeGreaterThanTheScheduledQuantity'));
+    return showFailToast(
+      proxy.t("task.taskQuantityCanNotBeGreaterThanTheScheduledQuantity")
+    );
   }
   if (proxy.compareTime(formData.data.startDate, formData.data.dueDate)) {
-    return showFailToast(proxy.t('task.completionDeadlineCanNotBeEarlierThanThePlanStartTime'));
+    return showFailToast(
+      proxy.t("task.completionDeadlineCanNotBeEarlierThanThePlanStartTime")
+    );
+  }
+  for (const key in productionObj.value) {
+    if (productionObj.value[key] && productionObj.value[key].length > 0) {
+    } else {
+      return showFailToast(proxy.t("所有工序都需选择负责人!"));
+    }
   }
+  formData.data.taskProcessesUser = JSON.stringify(productionObj.value);
   proxy.post("/productionTask/addByJxst", formData.data).then(
     (res) => {
       setTimeout(() => {
-        showSuccessToast(proxy.t('common.addSuccess'));
+        showSuccessToast(proxy.t("common.addSuccess"));
         proxy.$router.push("/main/jxskTask");
       }, 500);
     },
@@ -206,6 +301,37 @@ onMounted(() => {
     formOption.hiddenSubmitBtn = true; //隐藏提交按钮
   }
 });
+
+const handleSelectPeople = (val, index) => {
+  let currentUser = "";
+  for (let i = 0; i < val.length; i++) {
+    let userId = val[i];
+    const current = userList.value.find((x) => x.value === userId);
+    if (current && current.label) {
+      currentUser += current.label + "  ";
+    }
+  }
+  productionProcessesList.value[index].currentUser = currentUser;
+};
+
+const productionProcessesList = ref([]);
+const productionObj = ref({});
+const getProductionDetails = (id) => {
+  proxy.post("/productionPlan/detail", { id }).then((res) => {
+    productionProcessesList.value = res.data.productionProcessesList;
+    for (let i = 0; i < productionProcessesList.value.length; i++) {
+      const e = productionProcessesList.value[i];
+      e.showPicker = false;
+      e.currentUser = "";
+      formConfig.push({
+        type: "slot",
+        label: e.name + " 负责人",
+        slotName: e.id,
+      });
+      productionObj.value[e.id] = [];
+    }
+  });
+};
 </script>
 <style lang="scss" scoped>
 .row {

+ 53 - 8
src/views/MES/produce/plan/add.vue

@@ -22,6 +22,19 @@
           required
         />
         <van-popup v-model:show="typeModal" round position="bottom">
+          <div class="searchBox">
+            <van-search
+              v-model="searchKeyword"
+              show-action
+              label=""
+              placeholder="请输入搜索关键词"
+              @search="onSearchData()"
+            >
+              <template #action>
+                <div @click="onSearchData()">搜索</div>
+              </template>
+            </van-search>
+          </div>
           <van-picker
             :columns="columns"
             @cancel="typeModal = false"
@@ -67,6 +80,7 @@
         />
         <van-popup v-model:show="showPicker" position="bottom">
           <van-date-picker
+            v-model="currentDate"
             @confirm="onConfirmTime"
             @cancel="showPicker = false"
           />
@@ -113,15 +127,17 @@ const formData = ref({
 });
 
 const getDict = () => {
-  proxy.post("/workOrder/page", { pageNum: 1, pageSize: 9999 }).then((res) => {
-    columns.value = res.data.rows.map((item, index) => {
-      return {
-        ...item,
-        text: item.code,
-        value: item.id,
-      };
+  proxy
+    .post("/workOrder/page", { pageNum: 1, pageSize: 9999, isRemaining: "1" })
+    .then((res) => {
+      columns.value = res.data.rows.map((item, index) => {
+        return {
+          ...item,
+          text: item.code,
+          value: item.id,
+        };
+      });
     });
-  });
 };
 
 const getDetails = (id) => {
@@ -137,7 +153,13 @@ const getDetails = (id) => {
 
 const columns = ref([]);
 let isStart = ref(false);
+const currentDate = ref(["2023", "01", "01"]);
 const handleOpenTime = (type) => {
+  const date = new Date();
+  const year = date.getFullYear();
+  const month = date.getMonth() + 1;
+  const day = date.getDate();
+  currentDate.value = [year + "", month + "", day + ""];
   isStart.value = type;
   showPicker.value = true;
 };
@@ -192,6 +214,21 @@ const onSubmit = () => {
 onMounted(() => {
   getDict();
 });
+
+const searchKeyword = ref("");
+const onSearchData = () => {
+  proxy
+    .post("/workOrder/page", { keyword: searchKeyword.value, isRemaining: "1" })
+    .then((res) => {
+      columns.value = res.data.rows.map((item, index) => {
+        return {
+          ...item,
+          text: item.code,
+          value: item.id,
+        };
+      });
+    });
+};
 </script>
 <style lang="scss" scoped>
 .row {
@@ -208,4 +245,12 @@ onMounted(() => {
     text-align: center;
   }
 }
+
+::v-deep {
+  .searchBox {
+    .van-field__label--top {
+      width: 20px !important;
+    }
+  }
+}
 </style>

+ 13 - 9
src/views/MES/produce/plan/index.vue

@@ -7,7 +7,7 @@
       @click-left="onClickLeft"
       @click-right="onClickRight"
     >
-      <template #right> {{$t('common.add')}} </template>
+      <template #right> {{ $t("common.add") }} </template>
     </van-nav-bar>
     <van-search
       v-model="req.keyword"
@@ -50,20 +50,24 @@ const listData = ref([]);
 
 const listConfig = ref([
   {
-    label: proxy.t('plan.planTime'),
+    label: "计划单号",
+    prop: "code",
+  },
+  {
+    label: proxy.t("plan.planTime"),
     prop: "time",
   },
   {
-    label: proxy.t('plan.productName'),
+    label: proxy.t("plan.productName"),
     prop: "productName",
   },
 
   {
-    label: proxy.t('plan.planQuantity'),
+    label: proxy.t("plan.planQuantity"),
     prop: "quantity",
   },
   {
-    label: proxy.t('plan.planStatus'),
+    label: proxy.t("plan.planStatus"),
     prop: "statusName",
   },
 ]);
@@ -81,7 +85,7 @@ const onClickLeft = () => proxy.$router.push("/main/working");
 const onClickRight = () => {
   proxy.$router.push("/main/planAdd");
 };
-proxy.uploadDdRightBtn(onClickRight,proxy.t('common.add'))
+proxy.uploadDdRightBtn(onClickRight, proxy.t("common.add"));
 const toDtl = (row) => {
   proxy.$router.push({
     path: "planDtl",
@@ -101,11 +105,11 @@ const getList = (type) => {
         time: x.startDate + " ~ " + x.stopDate,
         statusName:
           x.status == 0
-            ? proxy.t('plan.notStarted')
+            ? proxy.t("plan.notStarted")
             : x.status == 1
-            ? proxy.t('plan.ongoing')
+            ? proxy.t("plan.ongoing")
             : x.status == 2
-            ? proxy.t('plan.complete')
+            ? proxy.t("plan.complete")
             : "",
       }));
       if (type === "refresh") {