Browse Source

工单管理

cz 2 years ago
parent
commit
3ac50f57e6

+ 28 - 0
src/components/MES/common-body.vue

@@ -0,0 +1,28 @@
+<template>
+  <div>
+    <van-form label-align="top">
+      <div v-for="(item, i) in data" :key="i" style="margin-bottom: 10px">
+        <van-field
+          v-for="x in config"
+          v-model="data[i][x.prop]"
+          readonly
+          :label="x.label"
+        />
+      </div>
+    </van-form>
+  </div>
+</template>
+<script setup>
+defineProps({
+  data: {
+    type: Object,
+    default: {},
+  },
+  config: {
+    type: Object,
+    default: [],
+  },
+});
+</script>
+<style lang="scss">
+</style>

+ 59 - 0
src/components/MES/common-top.vue

@@ -0,0 +1,59 @@
+<template>
+  <div class="common-list">
+    <ul>
+      <li>
+        <div class="center-content" style="line-height: 24px">
+          <div v-for="j in config" :key="j.prop">
+            <span class="left">{{ j.label }}</span
+            >{{ data[j.prop] }}
+          </div>
+        </div>
+      </li>
+    </ul>
+  </div>
+</template>
+<script setup>
+import { ref, getCurrentInstance, onMounted, defineProps } from "vue";
+const proxy = getCurrentInstance().proxy;
+defineProps({
+  data: {
+    type: Object,
+    default: {},
+  },
+  config: {
+    type: Object,
+    default: [],
+  },
+});
+
+const listCk = (item) => {
+  proxy.$emit("onClick", item);
+};
+</script>
+<style lang="scss">
+.common-list {
+  ul {
+    margin-top: 10px;
+    li {
+      list-style: none;
+      position: relative;
+      display: flex;
+      box-sizing: border-box;
+      align-items: center;
+      justify-content: space-between;
+      padding: 12px 16px;
+      background: #fff;
+      border-bottom: 1px solid #f1f1f1;
+      .center-content {
+        flex: 1;
+        .left {
+          margin-right: 15px;
+          color: #999999;
+        }
+      }
+      .left-box {
+      }
+    }
+  }
+}
+</style>

+ 17 - 1
src/router/index.js

@@ -77,7 +77,7 @@ const routes = [{
 			},
 			{
 				path: 'waitInboundAdd',
-				name: '入库',
+				name: '待入库>入库',
 				component: () => import('../views/purchase-sales/inbound-outbound/waitInbound/add.vue')
 			},
 
@@ -101,6 +101,22 @@ const routes = [{
 				name: '出入库流水',
 				component: () => import('../views/purchase-sales/inventory-management/outInList/index.vue')
 			},
+			// ***********************  MES模块路由     *********************** 
+			{
+				path: 'workOrder',
+				name: '工单管理',
+				component: () => import('../views/MES/workOrder/index.vue')
+			},
+			{
+				path: 'workOrderAdd',
+				name: '工单管理新增',
+				component: () => import('../views/MES/workOrder/add.vue')
+			},
+			{
+				path: 'workOrderDtl',
+				name: '工单管理详情',
+				component: () => import('../views/MES/workOrder/details.vue')
+			},
 		]
 	},
 

+ 177 - 0
src/views/MES/workOrder/add.vue

@@ -0,0 +1,177 @@
+<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.sourceName"
+          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.productName"
+          is-link
+          readonly
+          label="产品名称"
+          placeholder="选择产品名称"
+          @click="typeModalOne = true"
+          :rules="[{ required: true, message: '产品名称不能为空' }]"
+          required
+        />
+        <van-popup v-model:show="typeModalOne" round position="bottom">
+          <van-picker
+            :columns="columnsOne"
+            @cancel="typeModalOne = false"
+            @confirm="(data) => onConfirmOne(data, index)"
+          />
+        </van-popup>
+
+        <van-field
+          v-model="formData.quantity"
+          label="工单数量"
+          placeholder="请输入工单数量"
+          :rules="[{ required: true, message: '工单数量不能为空' }]"
+          required
+        />
+        <van-field
+          v-model="formData.remarks"
+          label="备注"
+          placeholder="请输入备注"
+          type="textarea"
+        />
+      </van-cell-group>
+
+      <div style="margin: 16px">
+        <van-button round block type="primary" native-type="submit">
+          提交
+        </van-button>
+      </div>
+    </van-form>
+  </div>
+</template>
+
+<script setup>
+import { ref, getCurrentInstance, onMounted } from "vue";
+import { showSuccessToast, showFailToast } from "vant";
+import { useRoute } from "vue-router";
+
+const proxy = getCurrentInstance().proxy;
+const route = useRoute();
+const typeModal = ref(false);
+const typeModalOne = ref(false);
+const formData = ref({
+  source: "",
+  sourceName: "",
+  productId: "1",
+  productName: "",
+  quantity: null,
+  remarks: "",
+});
+
+const getDict = () => {
+  proxy.post("/warehouse/page", { pageNum: 1, pageSize: 9999 }).then((res) => {
+    columns.value = res.data.rows.map((item, index) => {
+      return {
+        text: "ceshi来源" + index,
+        value: index * 10,
+      };
+    });
+    // formData.value.warehouseName = formData.value.warehouseId
+    //   ? columns.value.find((item) => item.value == formData.value.warehouseId).name
+    //   : null;
+  });
+
+  proxy
+    .post("/productInfo/page", { pageNum: 1, pageSize: 9999, definition: "1" })
+    .then((res) => {
+      columnsOne.value = res.data.rows.map((item) => {
+        return {
+          text: item.name,
+          value: item.id,
+        };
+      });
+      // formData.value.warehouseName = formData.value.warehouseId
+      //   ? columns.value.find((item) => item.value == formData.value.warehouseId).name
+      //   : null;
+    });
+};
+
+const getDetails = (id) => {
+  proxy.post("/stockJournal/detail", { id }).then((res) => {
+    formData.value = res.data;
+    list.value = res.data.list.map((x) => ({
+      productId: x.productId,
+      productName: x.productName,
+      quantity: x.quantity,
+    }));
+  });
+};
+
+const columns = ref([]);
+const columnsOne = ref([]);
+
+const onConfirm = ({ selectedOptions }) => {
+  formData.value.source = selectedOptions[0].value;
+  formData.value.sourceName = selectedOptions[0].text;
+  typeModal.value = false;
+};
+
+const onConfirmOne = ({ selectedOptions }, index) => {
+  formData.value.productId = selectedOptions[0].value;
+  formData.value.productName = selectedOptions[0].text;
+  typeModalOne.value = false;
+};
+
+const onClickLeft = () => history.back();
+
+const onSubmit = () => {
+  proxy.post("/workOrder/add", formData.value).then(
+    (res) => {
+      setTimeout(() => {
+        showSuccessToast("添加成功");
+        proxy.$router.push("/main/workOrder");
+      }, 500);
+    },
+    (err) => {
+      return showFailToast(err.message);
+    }
+  );
+};
+onMounted(() => {
+  getDict();
+});
+</script>
+<style lang="scss" scoped>
+.row {
+  display: flex;
+  padding: 5px 10px 0 10px;
+  justify-content: space-between;
+  align-items: center;
+  .title {
+    flex: 1;
+  }
+  .delete {
+    width: 20px;
+    cursor: pointer;
+    text-align: center;
+  }
+}
+</style>

+ 116 - 0
src/views/MES/workOrder/details.vue

@@ -0,0 +1,116 @@
+<template>
+  <div class="form" style="padding-bottom: 60px">
+    <van-nav-bar
+      title="工单管理"
+      left-text="返回"
+      left-arrow
+      @click-left="onClickLeft"
+    >
+    </van-nav-bar>
+
+    <div>
+      <common-top :data="formData" :config="topConfig"> </common-top>
+      <div style="line-height: 32px; color: #999999; padding: 0 15px">
+        生产计划
+      </div>
+      <common-body
+        :data="[
+          { time: '2022-01-09', quantity: '未完成', productName: '500' },
+          { time: '2022-01-09', quantity: '未完成', productName: '500' },
+          { time: '2022-01-09', quantity: '未完成', productName: '500' },
+        ]"
+        :config="bodyConfig"
+      >
+      </common-body>
+      <!-- <van-form label-align="top">
+        <div v-for="(item, index) in 3" :key="index" style="margin-top: 10px">
+          <van-field v-model="formData.productName" readonly label="计划日期" />
+          <van-field v-model="formData.productName" readonly label="计划数量" />
+          <van-field v-model="formData.productName" readonly label="计划状态" />
+        </div>
+      </van-form> -->
+    </div>
+  </div>
+</template>
+
+<script setup>
+import { ref, getCurrentInstance, onMounted } from "vue";
+import { useRoute } from "vue-router";
+
+import commonTop from "@/components/MES/common-top.vue";
+import commonBody from "@/components/MES/common-body.vue";
+
+const proxy = getCurrentInstance().proxy;
+const route = useRoute();
+
+const formData = ref({
+  source: "",
+  sourceName: "",
+  productId: "1",
+  productName: "",
+  quantity: null,
+  remarks: "",
+});
+
+const topConfig = ref([
+  {
+    label: "工单来源",
+    prop: "source",
+  },
+  {
+    label: "产品名称",
+    prop: "productName",
+  },
+  {
+    label: "工单数量",
+    prop: "quantity",
+  },
+  {
+    label: "工单状态",
+    prop: "status",
+  },
+]);
+
+const bodyConfig = ref([
+  {
+    label: "计划日期",
+    prop: "time",
+  },
+  {
+    label: "计划数量",
+    prop: "productName",
+  },
+  {
+    label: "计划状态",
+    prop: "quantity",
+  },
+]);
+
+const getDetails = (id) => {
+  proxy.post("/workOrder/detail", { id }).then((res) => {
+    formData.value = res.data;
+  });
+};
+
+const onClickLeft = () => history.back();
+
+onMounted(() => {
+  getDetails(route.query.id);
+});
+</script>
+<style lang="scss" scoped>
+.row {
+  display: flex;
+  padding: 5px 10px 0 10px;
+  justify-content: space-between;
+  align-items: center;
+  .title {
+    flex: 1;
+  }
+  .delete {
+    width: 20px;
+    cursor: pointer;
+    text-align: center;
+  }
+}
+</style>

+ 125 - 0
src/views/MES/workOrder/index.vue

@@ -0,0 +1,125 @@
+<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="请输入搜索关键词"
+      @search="onRefresh"
+    />
+
+    <van-pull-refresh v-model="loading" @refresh="onRefresh">
+      <div class="list">
+        <van-list
+          v-model:loading="loading"
+          :finished="finished"
+          finished-text="没有更多了"
+          @load="onLoad"
+          style="margin-bottom: 60px"
+        >
+          <commonList
+            :data="listData"
+            @onClick="toDtl"
+            :config="listConfig"
+          ></commonList>
+        </van-list>
+      </div>
+    </van-pull-refresh>
+  </div>
+</template>
+<script setup>
+import { ref, getCurrentInstance, onMounted } 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,
+  type: "1",
+  keyword: null,
+});
+const finished = ref(false);
+const proxy = getCurrentInstance().proxy;
+const listData = ref([]);
+
+const listConfig = ref([
+  {
+    label: "工单编号",
+    prop: "code",
+  },
+  {
+    label: "工单来源",
+    prop: "source",
+  },
+  {
+    label: "产品名称",
+    prop: "productName",
+  },
+  {
+    label: "工单数量",
+    prop: "quantity",
+  },
+  {
+    label: "工单状态",
+    prop: "status",
+  },
+]);
+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("/main/workOrderAdd");
+};
+
+const toDtl = (row) => {
+  proxy.$router.push({
+    path: "workOrderDtl",
+    query: {
+      id: row.id,
+    },
+  });
+};
+
+const getList = (type) => {
+  loading.value = true;
+  proxy
+    .post("/workOrder/page", req.value)
+    .then((res) => {
+      console.log(req.value);
+      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>

+ 22 - 108
src/views/purchase-sales/inbound-outbound/waitInbound/add.vue

@@ -9,6 +9,17 @@
     </van-nav-bar>
     <van-form @submit="onSubmit" label-align="top" style="margin-top: 20px">
       <van-cell-group inset>
+        <van-field v-model="formData.warehouseName" readonly label="数据来源" />
+        <van-field v-model="formData.warehouseName" readonly label="单号" />
+        <van-field v-model="formData.warehouseName" readonly label="物品名称" />
+        <van-field
+          v-model="formData.warehouseName"
+          readonly
+          label="待入库数量"
+        />
+      </van-cell-group>
+      <div style="padding: 5px 0 5px 15px; color: #999999">本次入库</div>
+      <van-cell-group inset>
         <van-field
           v-model="formData.warehouseName"
           is-link
@@ -26,59 +37,15 @@
             @confirm="onConfirm"
           />
         </van-popup>
-        <!-- 明细列表 -->
-        <div v-for="(item, index) in list" :key="index">
-          <div class="row">
-            <div class="title">明细{{ index + 1 }}</div>
-            <div
-              class="delete"
-              @click.native="handleDel(index)"
-              v-if="!route.query.id"
-            >
-              <van-icon name="cross" />
-            </div>
-          </div>
-          <van-field
-            v-model="list[index].productName"
-            is-link
-            readonly
-            label="物品名称"
-            placeholder="选择物品名称"
-            @click="handleSelect(index)"
-            :rules="[{ required: true, message: '物品名称不能为空' }]"
-            required
-          />
-
-          <van-field
-            v-model="list[index].quantity"
-            label="入库数量"
-            placeholder="请输入入库数量"
-            :rules="[{ required: true, message: '入库数量不能为空' }]"
-            required
-          />
-        </div>
-        <van-popup v-model:show="typeModalOne" round position="bottom">
-          <van-picker
-            :columns="columnsOne"
-            @cancel="typeModalOne = false"
-            @confirm="(data) => onConfirmOne(data, index)"
-          />
-        </van-popup>
+        <van-field
+          v-model="formData.warehouseName"
+          label="入库数量"
+          placeholder="请输入入库数量"
+          :rules="[{ required: true, message: '入库数量不能为空' }]"
+          required
+        />
       </van-cell-group>
-
-      <div style="text-align: center; line-height: 28px" v-if="!route.query.id">
-        <van-button
-          icon="plus"
-          type="primary"
-          plain
-          size="mini"
-          style="margin-top: 10px"
-          @click="handleAddRow"
-          >添加明细</van-button
-        >
-      </div>
-
-      <div style="margin: 16px" v-if="!route.query.id">
+      <div style="margin: 16px">
         <van-button round block type="primary" native-type="submit">
           提交
         </van-button>
@@ -94,23 +61,13 @@ import { useRoute } from "vue-router";
 
 const proxy = getCurrentInstance().proxy;
 const route = useRoute();
-const showPicker = ref(false);
 const typeModal = ref(false);
-const typeModalOne = ref(false);
-let selectIndex = ref(null);
 const formData = ref({
   warehouseId: "",
   type: "1",
   warehouseName: "",
 });
-const list = ref([]);
-const handleAddRow = () => {
-  list.value.push({
-    productId: "",
-    productName: "",
-    quantity: "",
-  });
-};
+
 const getDict = () => {
   proxy.post("/warehouse/page", { pageNum: 1, pageSize: 9999 }).then((res) => {
     columns.value = res.data.rows.map((item) => {
@@ -119,39 +76,16 @@ const getDict = () => {
         value: item.id,
       };
     });
-    // formData.value.warehouseName = formData.value.warehouseId
-    //   ? columns.value.find((item) => item.value == formData.value.warehouseId).name
-    //   : null;
   });
-
-  proxy
-    .post("/productInfo/page", { pageNum: 1, pageSize: 9999, definition: "1" })
-    .then((res) => {
-      columnsOne.value = res.data.rows.map((item) => {
-        return {
-          text: item.name,
-          value: item.id,
-        };
-      });
-      // formData.value.warehouseName = formData.value.warehouseId
-      //   ? columns.value.find((item) => item.value == formData.value.warehouseId).name
-      //   : null;
-    });
 };
 
 const getDetails = (id) => {
-  proxy.post("/stockJournal/detail", { id }).then((res) => {
+  proxy.post("/stockWait/detail", { id }).then((res) => {
     formData.value = res.data;
-    list.value = res.data.list.map((x) => ({
-      productId: x.productId,
-      productName: x.productName,
-      quantity: x.quantity,
-    }));
   });
 };
 
 const columns = ref([]);
-const columnsOne = ref([]);
 
 const onConfirm = ({ selectedOptions }) => {
   formData.value.warehouseId = selectedOptions[0].value;
@@ -159,30 +93,9 @@ const onConfirm = ({ selectedOptions }) => {
   typeModal.value = false;
 };
 
-const onConfirmOne = ({ selectedOptions }, index) => {
-  list.value[selectIndex.value].productId = selectedOptions[0].value;
-  list.value[selectIndex.value].productName = selectedOptions[0].text;
-  typeModalOne.value = false;
-};
-
-const handleSelect = (index) => {
-  selectIndex.value = index;
-  typeModalOne.value = true;
-};
-
-const handleDel = (index) => {
-  list.value.splice(index, 1);
-};
-
 const onClickLeft = () => history.back();
 
 const onSubmit = () => {
-  if (!list.value.length > 0) return showFailToast("请添加明细!");
-  formData.value.list = list.value.map((x) => ({
-    productId: x.productId,
-    quantity: x.quantity,
-  }));
-  formData.value.type = "1";
   proxy.post("/stock/add", formData.value).then(
     (res) => {
       setTimeout(() => {
@@ -195,6 +108,7 @@ const onSubmit = () => {
     }
   );
 };
+
 onMounted(() => {
   getDetails(route.query.id);
   getDict();

+ 7 - 4
src/views/purchase-sales/inbound-outbound/waitInbound/index.vue

@@ -21,6 +21,9 @@
           @onClick="toDtl"
           :config="listConfig"
         ></commonList>
+        <div>
+          <van-button type="success" @click="toDtl">成功按钮</van-button>
+        </div>
       </van-list>
     </div>
   </van-pull-refresh>
@@ -71,10 +74,10 @@ const onClickRight = () => {
 
 const toDtl = (row) => {
   proxy.$router.push({
-    path: "manualInboundAdd",
-    query: {
-      id: row.id,
-    },
+    path: "waitInboundAdd",
+    // query: {
+    //   id: row.id,
+    // },
   });
 };