陈龙 3 달 전
부모
커밋
8c1ef93169

+ 4 - 3
src/Auman.PieceWage.UniApp/components/easy-tab/easy-tab.vue

@@ -18,8 +18,7 @@
             }
         },
         data() {
-            return {
-            };
+            return {};
         },
         created() {
             this.items = [];
@@ -46,11 +45,11 @@
                     for (let i = 0; i < this.items.length; i++) {
                         if (this.items[i] === item) {
                             // this.items[i].select();
-                            this.current = i;
                             this.$emit('change', {
                                 before: this.current,
                                 current: i
                             });
+                            this.current = i;
                         } else {
                             this.items[i].unSelect();
                         }
@@ -68,5 +67,7 @@
         width: 100%;
         height: 80upx;
         flex-shrink: 0;
+        overflow-x: auto;
+        white-space: nowrap;
     }
 </style>

+ 137 - 57
src/Auman.PieceWage.UniApp/components/page-dispatch/page-dispatch.vue

@@ -1,25 +1,59 @@
 <template>
     <view class="flex direction-column height-100pre width-100per">
-        <uni-search-bar placeholder="单号、型号" style="width: 100%;"></uni-search-bar>
+        <view class="flex items-center padding-right">
+            <uni-search-bar placeholder="单号、型号" clearButton="none" class="grow-1" v-model="searchValue"
+                @confirm="load"></uni-search-bar>
+            <button size="mini" type="primary" @tap="load">搜索</button>
+        </view>
         <view class="flex padding-lr child-gap">
             <uni-datetime-picker type="date" placeholder="开始时间"></uni-datetime-picker>
             <uni-datetime-picker type="date" placeholder="结束时间"></uni-datetime-picker>
         </view>
         <view class="grow-1 height-0 scroll padding">
-            <view class="dispatch-row" v-for="(item, index) in list" key="number">
-                <view class="dispatch-row-title" @tap="openDetail()">{{item.title}}</view>
-                <view class="dispatch-row-cells child-gap">
-                    <view class="dispatch-row-cell width-40per">{{item.number}}</view>
-                    <view class="dispatch-row-cell grow-1">{{item.spec}}</view>
+            <view class="dispatch-row" v-for="(item, index) in items" key="number">
+                <view class="grow-1 padding-right">
+                    <view class="dispatch-row-cells child-gap">
+                        <view class="dispatch-row-title">{{item.orderNumber}}
+                        </view>
+                        <view class="dispatch-row-quantity">数量:{{item.quantity}}</view>
+                    </view>
+                    <view class="dispatch-row-cells child-gap">
+                        <view class="dispatch-row-cell grow-1">工艺:{{item.processName}}</view>
+                    </view>
+                    <view class="dispatch-row-cells child-gap">
+                        <view class="dispatch-row-cell grow-1">计划号:{{item.planNumber}}</view>
+                    </view>
+                    <view class="dispatch-row-cells child-gap">
+                        <view class="dispatch-row-cell grow-1">料号:{{item.inventoryNumber}}</view>
+                    </view>
+                    <view class="dispatch-row-cells child-gap">
+                        <view class="dispatch-row-cell grow-1">品名:{{item.inventoryName}}</view>
+                    </view>
+                    <view class="dispatch-row-cells child-gap">
+                        <view class="dispatch-row-cell grow-1">规格{{item.spec}}</view>
+                    </view>
+                </view>
+                <view class="shrink-0">
+                    <button size="mini" type="orange" @tap="buttonAction(item.dispatchOrderId)">{{buttonText}}</button>
                 </view>
             </view>
         </view>
+        
+        <view v-if="isAction">
+            <view>{{buttonText}}</view>
+        </view>
     </view>
 </template>
 
 <script>
     import extend from '../../utils/extend';
+import message from '../../utils/message';
     import request from '../../utils/request';
+    import url from '../../utils/url';
+    import user from '../../utils/user';
+
+    let userinfo = user.get();
+
     export default {
         name: "page-dispatch",
         props: {
@@ -27,75 +61,108 @@
                 type: String,
                 default: ''
             },
+            detailsUrl: {
+                type: String,
+                default: ''
+            },
             method: {
                 type: String,
                 default: 'get'
+            },
+            buttonText: {
+                type: String,
+                default: ''
+            },
+            buttonUrl: {
+                type: String,
+                default: ''
             }
         },
         data() {
             return {
-                list: [{
-                    title: '劳伦斯',
-                    number: 'C25412555',
-                    spec: '左扶1+右扶1+脚踏'
-                }, {
-                    title: '劳伦斯ds',
-                    number: 'C254125ert',
-                    spec: '左扶1+右扶1+脚踏'
-                }, {
-                    title: '劳ddsds',
-                    number: 'CD212244',
-                    spec: '左扶1+右扶1+脚踏'
-                }, {
-                    title: '劳gs',
-                    number: 'CD21552244',
-                    spec: '左扶1+右扶1+脚踏'
-                }, {
-                    title: '劳bdf',
-                    number: 'CS21552244',
-                    spec: '左扶1+右扶1+脚踏'
-                }, {
-                    title: 'hhhbdf',
-                    number: 'GCS21552244',
-                    spec: '左扶1+右扶1+脚踏'
-                }, {
-                    title: 'hhdggbdf',
-                    number: 'GC232244',
-                    spec: '左扶1+右扶1+脚踏'
-                }, {
-                    title: 'haadggbdf',
-                    number: 'GV3224de4',
-                    spec: '左扶1+右扶1+脚踏'
-                }]
+                searchValue: '',
+                items: [],
+                isAction: false
             };
         },
-        created(){
-            this.load();
-        },
         methods: {
-            async load(){
+            async load() {
                 if (extend.isEmptyString(this.url)) {
                     return;
                 }
                 uni.showLoading();
                 let res = await request.sendToken({
-                    url: this.url,
-                    method: this.method
+                    url: `${url.apiUrl}${this.url}`,
+                    method: this.method,
+                    data: {
+                        userId: userinfo.systemUserId
+                    }
                 });
                 uni.hideLoading();
                 console.log(res);
-                if (res.success) {} else {
+                if (res.success) {
+                    if (extend.isObject(res.data) && extend.isArray(res.data.rows)) {
+                        this.items = res.data.rows;
+                    }
+                } else {
                     uni.showModal({
                         title: '错误',
                         content: res.message
                     });
                 }
             },
-            
-            openDetail(){
-                uni.navigateTo({
-                    url: '/pages/dispatch/dispatch-detail'
-                })
+
+            openDetail() {
+                if (extend.isNonEmptyString(this.detailsUrl)) {
+                    uni.navigateTo({
+                        url: this.detailsUrl
+                    });
+                }
+            },
+
+            getRowById(id) {
+                let res = null;
+                for (let i = 0; i < this.items.length; i++) {
+                    if (this.items[i].dispatchOrderId === id) {
+                        res = this.items[i];
+                        break;
+                    }
+                }
+                return res;
+            },
+            buttonAction(id) {
+                this.isAction = true;
+            },
+
+            async action(id) {
+                let row = this.getRowById(id);
+                if (extend.isNull(row) && extend.isNonEmptyString(this.buttonUrl)) {
+                    return;
+                }
+                let r = await uni.showModal({
+                    title: '报工操作',
+                    content: `是否报工单号为 ${row.orderNumber} 的生产订单?`
+                });
+                console.log(r);
+                if (r.cancel) {
+                    return;
+                }
+                let res = await request.sendToken({
+                    url: `${url.apiUrl}${this.buttonUrl}`,
+                    method: 'post',
+                    data: [id]
+                });
+                if (res.success) {
+                    message.showSuccess({
+                        title: '已报工'
+                    });
+                    this.load();
+                } else {
+                    uni.showModal({
+                        title: '错误',
+                        content: res.message
+                    });
+                }
             }
         }
     }
@@ -104,22 +171,35 @@
 <style lang="scss">
     .dispatch-row {
         position: relative;
-        padding: 10upx 0;
-        
+        display: flex;
+        padding: 20upx 0;
+        align-items: center;
+
         .dispatch-row-title {
-            font-size: 32upx;
-            padding: 10upx 0;
+            font-size: 38upx;
         }
-        
+
+        .dispatch-row-quantity {
+            color: #666666;
+        }
+
         .dispatch-row-cells {
             position: relative;
             display: flex;
             font-size: 24upx;
             color: #666666;
+            justify-content: space-between;
+            align-items: center;
+            margin-top: 10upx;
+            flex-wrap: wrap;
         }
-        
+
         .dispatch-row-cell {
             flex-shrink: 0;
         }
     }
+
+    .dispatch-row+.dispatch-row {
+        border-top: 1upx solid #dfdfdf;
+    }
 </style>

+ 7 - 0
src/Auman.PieceWage.UniApp/pages.json

@@ -60,6 +60,13 @@
             {
                 "navigationBarTitleText" : "产品详情"
             }
+        },
+        {
+            "path" : "pages/dispatch/produce-dispatch",
+            "style" : 
+            {
+                "navigationBarTitleText" : "生产派工"
+            }
         }
     ],
     "globalStyle": {

+ 63 - 9
src/Auman.PieceWage.UniApp/pages/dispatch/dispatch.vue

@@ -1,28 +1,82 @@
 <template>
     <view class="flex direction-column height-100pre">
         <easy-tab type="line" @change="onTabChange">
-            <easy-tab-item>开料</easy-tab-item>
-            <easy-tab-item>断料</easy-tab-item>
-            <easy-tab-item>钉架子</easy-tab-item>
-            <easy-tab-item>打底</easy-tab-item>
+            <easy-tab-item v-for="(item, index) in process">{{item.processName}}</easy-tab-item>
         </easy-tab>
         <view class="flex grow-1 height-0 width-100per">
-            <page-dispatch :url="url" :method="method"></page-dispatch>
+            <page-dispatch ref="child" :url="url" :method="method" buttonText="派工" :buttonUrl="reportUrl"></page-dispatch>
         </view>
     </view>
 </template>
 
 <script>
+    import url from '../../utils/url';
+    import request from '../../utils/request';
+    import user from '../../utils/user';
+
+    let userinfo = user.get();
+
     export default {
         data() {
             return {
-                url: 'dispatch/search',
-                method: 'get'
+                url: 'dispatching-order/search',
+                reportUrl: 'produce/dispatch',
+                method: 'get',
+                process: []
             };
         },
+        async onLoad() {
+            await this.getProcess();
+            await this.getOrders();
+        },
+        async onShow() {
+            console.log('userinfo:', userinfo);
+        },
         methods: {
-            onTabChange(e){
+            onTabChange(e) {
                 console.log(e);
+            },
+
+            async getProcess() {
+                let res = await request.sendToken({
+                    url: `${url.apiUrl}process/search`,
+                    data: {
+                        name: '',
+                        groupNumber: '',
+                        // workshopSectionId: 0,
+                        opened: true
+                    }
+                });
+                if (res.success) {
+                    this.process = res.data.rows;
+                    console.log('process:', res.data.rows);
+                } else {
+                    uni.showModal({
+                        title: '错误',
+                        content: res.message
+                    });
+                }
+            },
+            
+            async getOrders(){
+                let res = await request.sendToken({
+                    url: `${url.apiUrl}dispatching-order/search`,
+                    data: {
+                        name: '',
+                        groupNumber: '',
+                        // workshopSectionId: 0,
+                        opened: true
+                    }
+                });
+                if (res.success) {
+                    this.process = res.data.rows;
+                    console.log('process:', res.data.rows);
+                } else {
+                    uni.showModal({
+                        title: '错误',
+                        content: res.message
+                    });
+                }
             }
         }
     }
@@ -30,4 +84,4 @@
 
 <style lang="scss">
 
-</style>
+</style>

+ 29 - 0
src/Auman.PieceWage.UniApp/pages/dispatch/produce-dispatch.vue

@@ -0,0 +1,29 @@
+<template>
+    <view>
+        
+    </view>
+</template>
+
+<script>
+    import extend from '../../utils/extend';
+    import request from '../../utils/request';
+    export default {
+        data() {
+            return {
+                dispatchingOrderId: 0
+            }
+        },
+        onLoad(opt) {
+            if (extend.isNonEmptyString(opt.dispatchingOrderId)) {
+                this.dispatchingOrderId = opt.dispatchingOrderId;
+            }
+        },
+        methods: {
+            async load(){}
+        }
+    }
+</script>
+
+<style>
+
+</style>

+ 3 - 3
src/Auman.PieceWage.UniApp/unpackage/dist/cache/.vite/deps/_metadata.json

@@ -1,8 +1,8 @@
 {
-  "hash": "37f1c7a0",
-  "configHash": "70247a0c",
+  "hash": "dd1f6c17",
+  "configHash": "2b2fe71f",
   "lockfileHash": "6d623abc",
-  "browserHash": "b62aff07",
+  "browserHash": "7ec04eca",
   "optimized": {},
   "chunks": {}
 }

+ 27 - 6
src/Auman.PieceWage.UniApp/utils/message.js

@@ -36,7 +36,7 @@ class Message {
         let _this = this;
         return new Promise((resolve, reject) => {
             if (opt.isPlayFailVoice) {
-                _this.tone.playDing();
+                _this.playDing();
             }
             uni.showModal({
                 title: opt.title,
@@ -79,7 +79,7 @@ class Message {
             opt.duration = 2000;
         }
         if (opt.isPlayFailVoice) {
-            this.tone.playDing();
+            this.playDing();
         }
         uni.showToast({
             icon: opt.icon,
@@ -112,7 +112,7 @@ class Message {
     }
 
     /**
-     * 显示消息提示
+     * 显示错误消息提示
      * @param {object} opt 参数
      * @param {string} opt.icon 图标,默认 error
      * @param {string} opt.title 标题
@@ -131,9 +131,30 @@ class Message {
         opt.isPlayFailVoice = true;
         this.show(opt);
     }
-    
-    playDing(){
-        this.tone.playDing();
+
+    /**
+     * 显示成功消息提示
+     * @param {object} opt 参数
+     * @param {string} opt.icon 图标,默认 success
+     * @param {string} opt.title 标题
+     * @param {number} opt.duration 提示的延迟时间,单位毫秒,默认:2000
+     * @param {boolean} opt.isPlayFailVoice 是否播放错误提示音, 默认 false
+     */
+    showSuccess(opt) {
+        if (!extend.isObject(opt)) {
+            opt = {};
+        }
+        opt.icon = 'success';
+        if (!extend.isString(opt.title)) {
+            opt.title = '';
+        }
+        opt.mask = true;
+        opt.isPlayFailVoice = true;
+        this.show(opt);
+    }
+
+    playDing() {
+        // this.tone.playDing();
     }
 }
 

+ 2 - 1
src/Auman.PieceWage.UniApp/utils/token.js

@@ -114,12 +114,13 @@ export default {
         if (res.success) {
             // 登录成功
             user.setLoginInfo(opts.data);
-            user.set(res.data);
             let token = res.data.token_type + ' ' + res.data.access_token;
             this.set({
                 token: token,
                 expires_in: res.data.expires_in
             });
+            
+            await user.getByServer();
         }
         return res;
     }

+ 38 - 0
src/Auman.PieceWage.UniApp/utils/user.js

@@ -1,5 +1,6 @@
 import extend from '../utils/extend.js';
 import request from './request.js';
+import message from './message.js';
 
 /**
  * 结果键
@@ -16,6 +17,11 @@ const infoKey = 'login_info';
  */
 const rememberKey = 'login_remember';
 
+/**
+ * 用户信息地址键
+ */
+const userUrlKey = 'user_url';
+
 /**
  * 用户类
  */
@@ -27,6 +33,12 @@ export default {
      * @param {string} opts.method 方法,合法值:get、post、put、delete,默认 get
      */
     async getByServer(opts) {
+        if (!extend.isObject(opts)) {
+            opts = {};
+        }
+        if (extend.isEmptyString(opts.url)) {
+            opts.url = this.getUserUrl();
+        }
         let res = await request.sendToken({
             url: opts.url
         });
@@ -34,6 +46,11 @@ export default {
             if (extend.isObject(res.data)) {
                 this.set(res.data);
             }
+            this.setUserUrl(opts.url);
+        } else {
+            message.error({
+                content: res.message
+            });
         }
         return res;
     },
@@ -74,6 +91,14 @@ export default {
         let info = extend.readStorage(rememberKey);
         return info;
     },
+    
+    /**
+     * 获取用户信息地址
+     */
+    getUserUrl(){
+        let url = extend.readStorage(userUrlKey);
+        return url;
+    },
 
     /**
      * 设置登录信息
@@ -105,6 +130,19 @@ export default {
         return false;
     },
 
+    /**
+     * 设置用户信息地址
+     * @param {object} url 用户信息地址
+     * @returns {boolean} 设置成功标记
+     */
+    setUserUrl(url) {
+        if (extend.isNonEmptyString(url)) {
+            extend.addStorage(userUrlKey, url);
+            return true;
+        }
+        return false;
+    },
+
     /**
      * 清除用户信息缓存
      */