LAPTOP-16IUEB3P\Lenovo 2 лет назад
Родитель
Сommit
a23999ae1b
3 измененных файлов с 111 добавлено и 54 удалено
  1. 11 1
      src/api/mainData/index.js
  2. 6 5
      src/api/workOrder/index.js
  3. 94 48
      src/views/workOrder/index.vue

+ 11 - 1
src/api/mainData/index.js

@@ -3,10 +3,20 @@ import request from '@/utils/request';
 /**
  * 分页查询生产版本
  */
-export async function versionPage (params) {
+export async function versionPage(params) {
   const res = await request.get(`/main/produceversion/page`, { params });
   if (res.data.code == 0) {
     return res.data.data;
   }
   return Promise.reject(new Error(res.data.message));
 }
+/**
+ * 班组列表
+ */
+export async function teamPage(params) {
+  const res = await request.get(`/main/team/page`, { params });
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 6 - 5
src/api/workOrder/index.js

@@ -2,11 +2,10 @@ import request from '@/utils/request';
 import store from '@/store';
 import Vue from 'vue';
 
-
 /**
  * 列表
  */
-export async function getList (params) {
+export async function getList(params) {
   const res = await request.post('/aps/workorder/page', params);
   if (res.data.code == 0) {
     return res.data.data;
@@ -15,10 +14,12 @@ export async function getList (params) {
 }
 
 // 下达
-export async function releaseWorkOrder(id) {
-  const res = await request.get(`/aps/workorder/releaseWorkOrder/${id}`);
+export async function releaseWorkOrder({ id, teamId }) {
+  const res = await request.get(
+    `/aps/workorder/releaseWorkOrder/${id}/${teamId}`
+  );
   if (res.data.code == 0) {
     return res.data.data;
   }
   return Promise.reject(new Error(res.data.message));
-}
+}

+ 94 - 48
src/views/workOrder/index.vue

@@ -1,12 +1,8 @@
 <template>
   <div class="ele-body">
     <el-card shadow="never" v-loading="loading">
-      <order-search
-        @search="reload"
-        ref="searchRef"
-      >
-      </order-search>
-<!--      <el-tabs v-model="activeName" type="card">
+      <order-search @search="reload" ref="searchRef"> </order-search>
+      <!--      <el-tabs v-model="activeName" type="card">
         <el-tab-pane label="未完成工单" name="first"></el-tab-pane>
         <el-tab-pane label="已完成工单" name="second"></el-tab-pane>
       </el-tabs> -->
@@ -19,7 +15,7 @@
       >
         <template v-slot:code="{ row }">
           <!-- <el-link type="primary" :underline="false" @click="goDetail(row)"> -->
-            {{ row.code }}
+          {{ row.code }}
           <!-- </el-link> -->
         </template>
         <template v-slot:status="{ row }">
@@ -29,41 +25,65 @@
         </template>
         <!-- 操作列 -->
         <template v-slot:action="{ row }">
-            <el-link
-              type="primary"
-              :underline="false"
-              icon="el-icon-truck"
-              @click="toRelease(row)"
-			  v-if="row.status==8"
-            >
-              下达
-            </el-link>
+          <el-link
+            type="primary"
+            :underline="false"
+            icon="el-icon-truck"
+            @click="toRelease(row)"
+            v-if="row.status == 8"
+          >
+            下达
+          </el-link>
         </template>
       </ele-pro-table>
     </el-card>
+
+    <el-dialog :visible.sync="visible" title="选择班组" width="400px">
+      <el-select v-model="releasParams.teamId">
+        <el-option
+          v-for="item in teamList"
+          :value="item.id"
+          :key="item.id"
+          :label="item.name"
+        ></el-option>
+      </el-select>
+
+      <div class="footer" slot="footer">
+        <el-button @click="visible = false">取消</el-button>
+        <el-button type="primary" @click="confirm">确定</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
 <script>
-  import { getList , releaseWorkOrder } from '@/api/workOrder/index.js';
+  import { getList, releaseWorkOrder } from '@/api/workOrder/index.js';
+  import { teamPage } from '@/api/mainData/index.js';
   import OrderSearch from './components/order-search.vue';
   export default {
     components: {
       OrderSearch
     },
-    data() {
+    data () {
       return {
-		loading:false,
+        visible: false,
+        loading: false,
+        releasParams: {
+          teamId: '',
+          id: ''
+        },
+        teamList: [],
+
         statusOpt: [
-            { label: '待生产', value: 4 },
-            { label: '生产中', value: 5 },
-            { label: '待下达', value: 8 }
-        ],
+          { label: '待生产', value: 4 },
+          { label: '生产中', value: 5 },
+          { label: '待下达', value: 8 }
+        ]
       };
     },
     computed: {
       // 表格列配置
-      columns() {
+      columns () {
         return [
           {
             columnKey: 'index',
@@ -143,9 +163,7 @@
             label: '状态',
             align: 'center',
             formatter: (row) => {
-              const obj = this.statusOpt.find(
-                (i) => i.value == row.status
-              );
+              const obj = this.statusOpt.find((i) => i.value == row.status);
               return obj && obj.label;
             }
           },
@@ -162,40 +180,68 @@
         ];
       }
     },
+    created () {
+      this._teamPage();
+    },
     methods: {
-      statusFormatter(status) {
-        const obj = this.statusOpt.find(
-          (i) => i.value == status
-        );
+      statusFormatter (status) {
+        const obj = this.statusOpt.find((i) => i.value == status);
         return obj && obj.label;
       },
       /* 表格数据源 */
-      datasource({ page, limit, where }) {
-		if(where.status){
-			where.statusList = []
-			where.statusList.push(where.status)
-		}
+      datasource ({ page, limit, where }) {
+        if (where.status) {
+          where.statusList = [];
+          where.statusList.push(where.status);
+        }
         return getList({
           pageNum: page,
           size: limit,
           ...where
         });
       },
+      async _teamPage () {
+        const res = await teamPage({ page: 1, size: -1 });
+
+        this.teamList = res.list;
+      },
       // 下达
-      toRelease(row) {
-		this.loading = true
-        releaseWorkOrder(row.id).then((res) => {
-			if(res){
-				this.$message.success('成功');
-				this.reload();
-			}
-			this.loading = false
-        }).catch(()=>{
-			 this.loading = false
-		})
+      toRelease (row) {
+        this.loading = true;
+        releaseWorkOrder(row.id)
+          .then((res) => {
+            if (res) {
+              this.$message.success('成功');
+              this.reload();
+            }
+            this.loading = false;
+          })
+          .catch(() => {
+            this.loading = false;
+          });
+        this.releasParams.id = row.id;
+        this.visible = true;
+      },
+      // 下达
+      confirm () {
+        if (!this.releasParams.teamId) {
+          return this.$message.error('请选择班组');
+        }
+        const loading = this.$loading({ text: '加载中...' });
+        releaseWorkOrder(this.releasParams)
+          .then((res) => {
+            if (res) {
+              this.$message.success('成功');
+              this.reload();
+              this.visible = false;
+            }
+          })
+          .finally(() => {
+            loading.close();
+          });
       },
       /* 刷新表格 */
-      reload(where) {
+      reload (where) {
         this.$nextTick(() => {
           this.$refs.table.reload({ page: 1, where });
         });