Kaynağa Gözat

确认信息

xiaohaizhao 2 ay önce
ebeveyn
işleme
0164b2cb90

+ 37 - 1
E-service/workOrder/confirm.js

@@ -89,7 +89,40 @@ Page({
       form,
       sa_workorderid: data.sa_workorderid
     })
+    if (data.attinfos.length) this.selectComponent("#Yl_Files").handleFiles(data.attinfos);
+  },
+  changeState({
+    detail
+  }) {
+    this.setData({
+      loading: detail
+    })
+  },
+  /* 绑定媒体 */
+  insertImgEdit({
+    detail
+  }) {
+    this.handleFileLink(detail)
+  },
 
+  handleFileLink(attachmentids, ownertable = "sa_workorder", ownerid = this.data.sa_workorderid) {
+    _Http.basic({
+      "classname": "system.attachment.Attachment",
+      "method": "createFileLink",
+      "content": {
+        ownertable,
+        ownerid,
+        usetype: 'default',
+        attachmentids
+      }
+    }).then(res => {
+      console.log('跟进记录绑定附件', res)
+      if (res.code != '1') return wx.showToast({
+        title: res.msg,
+        icon: "none"
+      })
+      this.selectComponent("#Yl_Files").handleFiles(res.data)
+    })
   },
   submit() {
     this.setData({
@@ -108,7 +141,7 @@ Page({
       })
       console.log("确认信息", res)
       if (res.code == 1) {
-        getCurrentPages().find(v => v.__route__ == 'E-service/workOrder/detail').getDetail();
+        if (res.msg != '成功') return;
         wx.navigateBack({
           success() {
             wx.showToast({
@@ -142,5 +175,8 @@ Page({
     this.setData({
       disabled: detail
     })
+  },
+  onUnload() {
+    getCurrentPages().find(v => v.__route__ == 'E-service/workOrder/detail').getDetail();
   }
 })

+ 4 - 1
E-service/workOrder/confirm.json

@@ -1,3 +1,6 @@
 {
-  "usingComponents": {}
+  "usingComponents": {
+    "Yl_Upload": "/components/Yl_Upload/index",
+    "Yl_Files": "/components/Yl_Files/index"
+  }
 }

+ 39 - 0
E-service/workOrder/confirm.scss

@@ -1,3 +1,42 @@
+.box {
+	width: 100vw;
+	box-sizing: border-box;
+	margin-top: 20rpx;
+	background-color: #fff;
+
+	.content {
+			border-radius: 8rpx;
+			padding: 0 30rpx;
+			box-sizing: border-box;
+
+			.upload {
+					display: flex;
+					align-items: center;
+					width: 100%;
+					height: 88rpx;
+					box-sizing: border-box;
+
+					.title {
+							flex: 1;
+							font-size: 28rpx;
+							font-family: PingFang SC-Regular, PingFang SC;
+							color: #333333;
+							font-weight: bold;
+					}
+
+					navigator {
+							width: 100rpx;
+							height: 80rpx;
+							line-height: 80rpx;
+							text-align: center;
+							padding: 0;
+					}
+			}
+
+	}
+}
+
+
 .new-footer {
 	display: flex;
 	align-items: center;

+ 18 - 0
E-service/workOrder/confirm.wxml

@@ -1,5 +1,23 @@
 <Yl_Headline title='基本信息' type='switch' switchLabel='仅显示必填信息' switch='{{showAll}}' bind:callBack='onChange' />
 <Yl_Field id='Form' form='{{form}}' showAll='{{!showAll}}' bind:onConfirm='onConfirm' bind:interrupt="interrupt" />
+<view class="box">
+    <view class="content">
+        <view class="upload">
+            <view class="title">{{language['附件']||'附件'}}</view>
+            <Yl_Upload accept='media' binduploadCallback="insertImgEdit" bindchangeState='changeState'>
+                <navigator url="#">
+                    <text class="iconfont icon-a-tonggaofujian" />
+                </navigator>
+            </Yl_Upload>
+            <Yl_Upload accept='file' binduploadCallback="insertImgEdit" bindchangeState='changeState'>
+                <navigator url="#">
+                    <text class="iconfont icon-a-biaoqianlanzhiku" />
+                </navigator>
+            </Yl_Upload>
+        </view>
+    </view>
+    <Yl_Files delete id="Yl_Files" strict ownertable="sa_workorder" />
+</view>
 <view style="height: 150rpx;" />
 <view class="new-footer">
     <van-button custom-class='new-submit' disabled='{{disabled || loading}}' loading='{{loading}}' bindclick='submit'>{{language['确定']||'确定'}}</van-button>

+ 35 - 19
E-service/workOrder/detail.js

@@ -35,7 +35,8 @@ Page({
     reason: {
       abortreason: ""
     },
-    abortreasonShow: false
+    abortreasonShow: false,
+    isqQuery: false
   },
   onLoad(options) {
     getApp().globalData.Language.getLanguagePackage(this, '工单详情');
@@ -255,7 +256,10 @@ Page({
   /* 底部功能 */
   async setTabbar() {
     let status = this.data.detail.status,
-      tabbarList = [];
+      tabbarList = [],
+      isLeader = this.data.detail.team.find(v => v.isleader) == wx.getStorageSync("userMsg").userid,
+      isqQuery = this.data.isqQuery,
+      isworkleader = this.data.isworkleader || false;
     let options = {
       编辑: {
         icon: "icon-bianji2",
@@ -290,26 +294,38 @@ Page({
         label: "中止"
       }
     };
-
-    let userMsg = wx.getStorageSync("userMsg"),
-      isAdmin = userMsg.hrid == 0 && userMsg.usertype == 0;
-    /* '确认信息',
-    '确认信息', */
+    if (!isLeader && !isqQuery) await _Http.basic({
+      "id": 2025062416033402,
+      "content": {
+        "userid": wx.getStorageSync('userMsg').userid,
+        "sa_workorderid": this.data.detail.sa_workorderid,
+      },
+    }).then(res => {
+      console.log("重新是否服务主管", res)
+      if (res.code == 1) {
+        isworkleader = res.data.isworkleader
+        this.setData({
+          isworkleader: res.data.isworkleader,
+          isqQuery: true,
+          isLeader
+        })
+      }
+    })
     let statusOptions = {
-      待接单: ['编辑', '转工单', '接单', '中止'],
-      待开始: ['编辑', '开始工单', '中止'],
-      进行中: ['编辑', '完结工单', '暂停', '中止'],
-      暂停: ['编辑', '启用', '中止'],
+      待接单: ['接单', '中止'],
+      待开始: ['开始工单', '中止'],
+      进行中: ['完结工单', '暂停', '中止'],
+      暂停: ['启用', '中止'],
     };
-
-    /*  if (isAdmin) {
-       statusOptions.新建 = [];
-       statusOptions.已提交 = [];
-     } */
-    /*     const appAuth = wx.getStorageSync('auth').applyBill;
-        appAuth.optionnames = ['查询', '转工单', '退回', '中止']
-        statusOptions.已提交 = appAuth.optionnames.filter(v => ['转工单', '退回', '中止'].includes(v)) */
     if (statusOptions[status]) {
+      if (!isLeader) statusOptions[status] = [];
+      if (isLeader || isworkleader) {
+        if (status == '待接单') {
+          statusOptions[status] = ["编辑", '转工单'].concat(statusOptions[status])
+        } else {
+          statusOptions[status].unshift("编辑");
+        }
+      }
       tabbarList = statusOptions[status].map(v => options[v]);
     }
     this.setData({

+ 2 - 2
E-service/workOrder/detail.wxml

@@ -48,7 +48,7 @@
 		<view class="value">{{detail.enddate}}</view>
 	</view>
 	<view class="buts">
-		<navigator class="confirm but" url="/E-service/workOrder/confirm?id={{sa_workorderid}}">
+		<navigator wx:if="{{isworkleader || isLeader}}" class="confirm but" url="/E-service/workOrder/confirm?id={{sa_workorderid}}">
 			{{language['查看工单确认信息']||'查看工单确认信息'}}
 		</navigator>
 		<navigator class="start but" url="/E-service/workOrder/confirm?id={{sa_workorderid}}">
@@ -59,7 +59,7 @@
 <view style="height: 20rpx;" />
 <Yl_FunTabs list='{{tabsList}}' showIcon='{{false}}' active='{{tabsActive}}' bind:onChenge="tabsChange">
 	<Preview slot='工单信息' list1='{{list1}}' list2='{{list2}}' />
-	<view style="height: 150rpx;" />
+	<view style="height: 180rpx;" />
 </Yl_FunTabs>
 
 <Yl_Tabbar wx:if="{{tabbarList.length}}" list='{{tabbarList}}' bind:callback="tabbarOnClick" />

+ 1 - 1
components/Yl_Attachment/index.wxml

@@ -16,7 +16,7 @@
 	</view>
 </view>
 
-<Yl_Files id="Yl_Files" delete='{{!disabled}}' binddeleteCallBack='deleteFiles' />
+<Yl_Files id="Yl_Files" delete='{{!disabled}}' bindonDeteleFiles='deleteFiles' />
 <block wx:if="{{content.total==0}}">
 	<Yl_Empty />
 	<view style="height: 100rpx;" />

+ 103 - 33
components/Yl_Files/index.js

@@ -17,12 +17,28 @@ Component({
         delete: {
             type: Boolean
         },
-        deleteCallBack: {
+        onDeteleFiles: {
             type: Function
+        },
+        padding: {
+            type: String,
+            value: '0 30rpx'
+        },
+        strict: {
+            type: Boolean
+        },
+        attinfos: {
+            type: Array
+        }
+    },
+    observers: {
+        'attinfos': function (attinfos) {
+            this.initData();
+            this.handleFiles(attinfos, true)
         }
     },
     methods: {
-        /* 预览媒体 */
+        /* 预览媒体 */
         viewMedias(e) {
             const {
                 index,
@@ -33,7 +49,7 @@ Component({
                 sources: type == 'image' ? this.data.files.viewImages : this.data.files.viewVideos,
             })
         },
-        /* 预览文档 */
+        /* 预览文档 */
         viewFlies(e) {
             const {
                 item
@@ -64,37 +80,54 @@ Component({
         },
         /* 删除文件 */
         handleDeleteFile(e) {
-            let item = e.currentTarget.dataset.item || e.currentTarget.dataset.item;
-            _Http.basic({
-                "classname": "system.attachment.Attachment",
-                "method": "deleteFileLink",
-                "content": {
-                    "linksids": [item.linksid]
-                }
-            }).then(res => {
-                if (res.code != '1') return wx.showToast({
-                    title: res.msg,
-                    icon: "none"
+            let that = this;
+            if (this.data.strict) {
+                wx.showModal({
+                    title: getApp().globalData.Language.getMapText('提示'),
+                    content: getApp().globalData.Language.getMapText('是否确定删除该附件'),
+                    cancelText: getApp().globalData.Language.getMapText('取消'),
+                    confirmText: getApp().globalData.Language.getMapText('确定'),
+                    complete: (res) => {
+                        if (res.confirm) start()
+                    }
+                })
+            } else {
+                start()
+            }
+
+            function start() {
+                let item = e.currentTarget.dataset.item || e.currentTarget.dataset.item;
+                _Http.basic({
+                    "classname": "system.attachment.Attachment",
+                    "method": "deleteFileLink",
+                    "content": {
+                        "linksids": [item.linksid]
+                    }
+                }).then(res => {
+                    if (res.code != '1') return wx.showToast({
+                        title: res.data,
+                        icon: "none"
+                    });
+                    let files = that.data.files;
+                    switch (item.fileType) {
+                        case "image":
+                            files.images = files.images.filter(v => v.url != item.url);
+                            files.viewImages = files.viewImages.filter(v => v.url != item.url);
+                            break;
+                        case "video":
+                            files.videos = files.videos.filter(v => v.url != item.url);
+                            files.viewVideos = files.viewVideos.filter(v => v.url != item.url);
+                            break;
+                        default:
+                            files.files = files.files.filter(v => v.attachmentid != item.attachmentid);
+                            break;
+                    };
+                    that.setData({
+                        files
+                    });
+                    that.triggerEvent("onDeteleFiles", that.getFiles())
                 });
-                let files = this.data.files;
-                switch (item.fileType) {
-                    case "image":
-                        files.images = files.images.filter(v => v.url != item.url);
-                        files.viewImages = files.viewImages.filter(v => v.url != item.url);
-                        break;
-                    case "video":
-                        files.videos = files.videos.filter(v => v.url != item.url);
-                        files.viewVideos = files.viewVideos.filter(v => v.url != item.url);
-                        break;
-                    default:
-                        files.files = files.files.filter(v => v.attachmentid != item.attachmentid);
-                        break;
-                };
-                this.setData({
-                    files
-                });
-                this.triggerEvent("deleteCallBack")
-            })
+            }
         },
         /* 处理附件 */
         handleFiles(arr, init = false) {
@@ -144,5 +177,42 @@ Component({
                 }
             })
         },
+        /* 返回数据ID数组 用来换绑数据 */
+        getFiles() {
+            let data = {
+                    attachmentids: [],
+                    list: [],
+                },
+                files = this.data.files;
+            files.files.forEach(v => {
+                data.attachmentids.push(v.attachmentid);
+                data.list.push(v);
+            })
+            files.images.forEach(v => {
+                data.attachmentids.push(v.attachmentid);
+                data.list.push(v);
+            })
+            files.videos.forEach(v => {
+                data.attachmentids.push(v.attachmentid);
+                data.list.push(v);
+            });
+            return data
+        },
+        deleteAll() {
+            let linksids = this.getFiles().list.map(v => v.linksid);
+            if (linksids.length) _Http.basic({
+                "classname": "system.attachment.Attachment",
+                "method": "deleteFileLink",
+                "content": {
+                    linksids
+                }
+            }).then(res => {
+                console.log("删除所有未保存附件", linksids, res)
+                if (res.code != '1') return wx.showToast({
+                    title: res.data,
+                    icon: "none"
+                });
+            });
+        }
     }
 })

+ 0 - 1
components/Yl_Files/index.scss

@@ -3,7 +3,6 @@
     display: flex;
     flex-wrap: wrap;
     margin-top: 20rpx;
-    padding: 0 30rpx;
     box-sizing: border-box;
 
     .item {

+ 1 - 1
components/Yl_Files/index.wxml

@@ -1,4 +1,4 @@
-<view class="media">
+<view class="media" style="padding:{{padding}};">
     <!-- 图片 -->
     <navigator url="#" class="item" wx:for="{{files.images}}" wx:key="attachmentid">
         <image src="{{item.url}}" data-index="{{index}}" data-type='image' mode="aspectFill" bindtap="viewMedias" />

+ 5 - 0
components/Yl_Upload/index.js

@@ -22,6 +22,9 @@ Component({
         parentid: {
             type: String,
             value: wx.getStorageSync('siteP').appfolderid
+        },
+        changeState: {
+            type: Function
         }
     },
 
@@ -38,6 +41,7 @@ Component({
     methods: {
         /* 上传文件 */
         afterRead(event) {
+            this.triggerEvent("changeState", true)
             for (let i = 0; i < event.detail.file.length; i++) {
                 // 初始化数据
                 let that = this,
@@ -101,6 +105,7 @@ Component({
                         console.log("文件上传反馈", s)
                         // if (s.code != 1) return;
                         that.triggerEvent("uploadCallback", s.data.attachmentids);
+                        that.triggerEvent("changeState", false)
                     }).catch(err => {
                         console.log(err)
                     })

+ 9 - 2
project.private.config.json

@@ -24,12 +24,19 @@
   "condition": {
     "miniprogram": {
       "list": [
+        {
+          "name": "E-service/workOrder/detail",
+          "pathName": "E-service/workOrder/detail",
+          "query": "id=1389",
+          "scene": null,
+          "launchMode": "default"
+        },
         {
           "name": "老工单详情",
           "pathName": "/Eservice/workerLeader/editworkOrderDetail/index",
           "query": "id=1387",
-          "scene": null,
-          "launchMode": "default"
+          "launchMode": "default",
+          "scene": null
         },
         {
           "name": "工单详情",