Ver código fonte

调整移动端的费用报销

Lijy 1 ano atrás
pai
commit
0cc31b3120

+ 1 - 1
fhKeeper/formulahousekeeper/timesheet_h5/src/utils/request.js

@@ -15,7 +15,7 @@ service.interceptors.request.use(
         if(config.url == "/report/record") {
             console.log('执行力')
             config.headers["Content-Type"] = "multipart/form-data";
-        } else if(config.url != "/report/editReport" && config.url != "/project/editProject" && config.url != "/common/uploadFile" && config.url != "/project/editProject") {
+        } else if(config.url != "/report/editReport" && config.url != "/project/editProject" && config.url != "/common/uploadFile" & config.url != "/common/uploadFileArray" && config.url != "/project/editProject") {
             config.data = qs.stringify(config.data);
             config.headers["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
         } else {

+ 163 - 24
fhKeeper/formulahousekeeper/timesheet_h5/src/views/expense/details.vue

@@ -5,7 +5,7 @@
             <!-- 报销人 -->
             <van-field
                 label="报销人"
-                @click="ownerIdShow = true"
+                @click="ownerIdShowCli(1)"
                 readonly
                 clickable
                 required
@@ -15,6 +15,22 @@
                     <span v-else>{{formshowText.name}}</span>
                 </template>
             </van-field>
+            <div v-if="auditTypeItem.auditType == 2">
+                <van-field label="第一审核人" @click="ownerIdShowCli(2)" readonly clickable required :disabled="editForm.reviewProcess > 0">
+                    <template #input>
+                        <span v-if="user.userNameNeedTranslate == 1"><ww-open-data type='userName'
+                                :openid='firstCheckerText.name'></ww-open-data></span>
+                        <span v-else>{{ firstCheckerText.name }}</span>
+                    </template>
+                </van-field>
+                <van-field label="第二审核人" @click="ownerIdShowCli(3)" readonly clickable required :disabled="editForm.reviewProcess > 1">
+                    <template #input>
+                        <span v-if="user.userNameNeedTranslate == 1"><ww-open-data type='userName'
+                                :openid='secondCheckerText.name'></ww-open-data></span>
+                        <span v-else>{{ secondCheckerText.name }}</span>
+                    </template>
+                </van-field>
+            </div>
             <van-popup v-model="ownerIdShow" position="bottom" v-if="false">
                 <van-picker
                     value-key="name"
@@ -155,20 +171,35 @@
                     ><template #input>¥{{getTaxValue(item.amount,item.taxPercent)}}</template></van-field>
                     <van-field label="备注:" v-model="item.remark" :readonly="!canEdit"></van-field>
                     <van-field
-                        label="报销凭证:"
                         @click="invoiceIndex = index"
                         :clickable="!canEdit"
+                        label-width="0em"
                     >
                         <template #input>
-                            <van-uploader
-                                v-model="uploader[index]"
-                                :before-read="beforeRead"
-                                :after-read="afterRead"
-                                @delete="item.pic = null"
-                                :max-count="1"
-                                :disabled="!canEdit"
-                                :deletable="canEdit"
-                            />
+                            <div class="imgListVan">
+                                <div>报销凭证:</div>
+                                <div class="vanUploaderImg">
+                                    <!-- <van-uploader
+                                        v-model="uploader[index]"
+                                        :before-read="beforeRead"
+                                        :after-read="afterRead"
+                                        @delete="item.pic = null"
+                                        :max-count="1"
+                                        :disabled="!canEdit"
+                                        :deletable="canEdit"
+                                    /> -->
+                                    <van-uploader
+                                        v-model="uploader[index]"
+                                        :before-read="beforeRead"
+                                        :after-read="afterRead"
+                                        @delete="(file, Item) => {deteleImg(file, Item, index)}"
+                                        :max-count="10"
+                                        :disabled="!canEdit"
+                                        :deletable="canEdit"
+                                        multiple
+                                    />
+                                </div>
+                            </div>
                         </template>
                     </van-field>
                     <van-field
@@ -320,7 +351,10 @@ export default {
             uploader: [[]],
              expenseMainType:{
                 text:''
-            }
+            },
+            firstCheckerText: {},
+            secondCheckerText: {},
+            auditTypeItem: {}
         }
     },
     computed: {
@@ -350,7 +384,7 @@ export default {
     mounted() {
         console.log(this.$route.params);
         this.isAudit = this.$route.params.isAudit;
-        
+        this.getAuditType()
         this.getDetail()
         if(this.canEdit){
             this.getProjectList()
@@ -471,24 +505,58 @@ export default {
         },
 
         beforeRead(file){
-            if(file.type != 'image/jpeg' && file.type != 'image/png'){
-                this.$toast.fail('请选择jpg或png格式的图片')
-                return false
+            // if(file.type != 'image/jpeg' && file.type != 'image/png'){
+            //     this.$toast.fail('请选择jpg或png格式的图片')
+            //     return false
+            // }
+            // return true
+
+            let newFile = Array.isArray(file) ? file : [file]
+            for(var i in newFile) {
+                const fileItem = newFile[i]
+                if (fileItem.type != 'image/jpeg' && fileItem.type != 'image/png' && fileItem.type != 'image/jpg') {
+                    this.$toast.fail('请选择jpg或png格式的图片')
+                    return false
+                }
             }
             return true
         },
         afterRead(file){
+            // let formData = new FormData();
+            // formData.append("multipartFile", file.file);
+            // this.$axios.post("/common/uploadFile", formData)
+            // .then(res => {
+            //     if(res.code == "ok") {
+            //         this.invoiceList[this.invoiceIndex].pic = res.data
+            //     } else {
+            //         this.$toast.fail('上传失败');
+            //         this.uploader[this.invoiceIndex] = []
+            //     }
+            // }).catch(err=> {this.$toast.clear();console.log(err);this.uploader[this.invoiceIndex]=[]});
+
+            let newFile = Array.isArray(file) ? file : [file]
             let formData = new FormData();
-            formData.append("multipartFile", file.file);
-            this.$axios.post("/common/uploadFile", formData)
+            for(var i in newFile) {
+                formData.append("multipartFiles", newFile[i].file);
+            }
+            this.$axios.post("/common/uploadFileArray", formData)
             .then(res => {
-                if(res.code == "ok") {
-                    this.invoiceList[this.invoiceIndex].pic = res.data
+                if (res.code == "ok") {
+                    let newPic = this.invoiceList[this.invoiceIndex].pic || []
+                    let newData = res.data.split(';')
+                    this.invoiceList[this.invoiceIndex].pic = [...newPic, ...newData]
+                    console.log(this.invoiceList[this.invoiceIndex].pic, '<=== 合计图片')
                 } else {
                     this.$toast.fail('上传失败');
                     this.uploader[this.invoiceIndex] = []
                 }
-            }).catch(err=> {this.$toast.clear();console.log(err);this.uploader[this.invoiceIndex]=[]});
+            }).catch(err => { this.$toast.clear(); console.log(err); this.uploader[this.invoiceIndex] = [] });
+        },
+
+        // 删除图片
+        deteleImg(file, item, arrIndex) {
+            let index = item.index
+            this.invoiceList[arrIndex].pic = this.invoiceList[arrIndex].pic.filter((item,i) => i != index)
         },
 
         submitExpense(){
@@ -500,6 +568,17 @@ export default {
                 this.$toast.fail('请选择填报日期')
                 return
             }
+
+            if(this.auditTypeItem.auditType == 2) {
+                if(!this.firstCheckerText.id || !this.secondCheckerText.id) {
+                    this.$toast.fail(`${!this.firstCheckerText.id ? '请选择第一审核人' : '请选择第二审核人'}`)
+                    return
+                } else {
+                    this.editForm.firstCheckerId = this.firstCheckerText.id
+                    this.editForm.secondCheckerId = this.secondCheckerText.id
+                }
+            }
+
             let required1 = false
             let required2 = false
             let required3 = false
@@ -532,8 +611,17 @@ export default {
                 this.$toast.fail('请添加发票的[' + requiredStr + ']')
                 return
             }
+
+            let newList = JSON.parse(JSON.stringify(this.invoiceList))
+            for(let i in newList) {
+                if(newList[i].pic) {
+                    newList[i].pic = newList[i].pic.join(',')
+                }
+            }
+
             delete this.editForm.invoiceList
-            this.editForm.items = JSON.stringify(this.invoiceList)
+            // this.editForm.items = JSON.stringify(this.invoiceList)
+            this.editForm.items = JSON.stringify(newList)
             this.editForm.totalAmount = this.totalCost
             this.confirmLoading = true
             this.$axios.post("/expense-sheet/add", this.editForm)
@@ -558,13 +646,30 @@ export default {
                     if(this.canEdit){this.getExTypeList()}
                     this.formshowText.name = res.data.ownerName
                     this.totalCost = res.data.totalAmount
-
                     this.invoiceList = res.data.invoiceList
+                    if(this.auditTypeItem.auditType == 2) {
+                        this.firstCheckerText = {
+                            id: res.data.firstCheckerId,
+                            name: res.data.firstCheckerName
+                        }
+                        this.secondCheckerText = {
+                            id: res.data.secondCheckerId,
+                            name: res.data.secondCheckerName
+                        }
+                    }
                     for(let i in res.data.invoiceList){
                         this.formshowText.inProjectName.push(res.data.invoiceList[i].projectName)
                         res.data.invoiceList[i].approveLoading = false;
                         if(res.data.invoiceList[i].pic){
-                            this.uploader[i] = [{url:'/upload/' + res.data.invoiceList[i].pic}]
+                            // this.uploader[i] = [{url:'/upload/' + res.data.invoiceList[i].pic}]
+                            let pic = res.data.invoiceList[i].pic
+                            let picArr = pic.split(',').map(item => {
+                                return { url: `/upload/${item}`}
+                                // return { url: `http://47.101.180.183/upload/${item}`}
+                            })
+                            res.data.invoiceList[i].pic = pic.split(',').map(item => item)
+                            this.uploader[i] = picArr
+                            console.log('每一项的图片', picArr)
                         }else{
                             this.uploader[i] = []
                         }
@@ -634,6 +739,24 @@ export default {
                     }
                 }).catch(err => { this.$toast.clear(); console.log(err) });
         },
+        getAuditType() {
+            this.$axios.post("/expense-audit-setting/get", {})
+                .then(res => {
+                    if (res.code == "ok") {
+                        this.auditTypeItem = res.data;
+                    } else {
+                        this.$message({
+                            message: res.msg,
+                            type: "error"
+                        });
+                    }
+                }).catch(err => { this.$toast.clear(); console.log(err) });
+        },
+        ownerIdShowCli(type) {
+            this.ownerIdShowType = type
+            this.userRadio = ''
+            this.ownerIdShow = true
+        }
     },
 };
 </script>
@@ -671,6 +794,22 @@ export default {
                 text-align: right;
             }
     }
+    .imgListVan {
+        display: flex;
+        flex-direction: column;
+    }
+    .vanUploaderImg {
+        // display: flex;
+        margin-top: 6px;
+        /deep/ .van-uploader__preview-image {
+            width: 70px;
+            height: 70px;
+        }
+        /deep/ .van-uploader__upload {
+            width: 70px;
+            height: 70px;
+        }
+    }
 }
 .waiting {
     color: orange;

+ 135 - 32
fhKeeper/formulahousekeeper/timesheet_h5/src/views/expense/index.vue

@@ -11,27 +11,30 @@
             <div class="edit" v-if="active == 0">
                 <van-form class="edit_form" label-width="140">
                     <!-- 报销人 -->
-                    <van-field label="报销人" @click="ownerIdShow = true" readonly clickable required>
+                    <van-field label="报销人" @click="ownerIdShowCli(1)" readonly clickable required>
                         <template #input>
                             <span v-if="user.userNameNeedTranslate == 1 && formshowText.name"><ww-open-data type='userName'
                                     :openid='formshowText.name'></ww-open-data></span>
                             <span v-else>{{ formshowText.name }}</span>
                         </template>
                     </van-field>
+                    <div v-if="auditTypeItem.auditType == 2">
+                        <van-field label="第一审核人" @click="ownerIdShowCli(2)" readonly clickable required>
+                            <template #input>
+                                <span v-if="user.userNameNeedTranslate == 1"><ww-open-data type='userName'
+                                        :openid='firstCheckerText.name'></ww-open-data></span>
+                                <span v-else>{{ firstCheckerText.name }}</span>
+                            </template>
+                        </van-field>
+                        <van-field label="第二审核人" @click="ownerIdShowCli(3)" readonly clickable required>
+                            <template #input>
+                                <span v-if="user.userNameNeedTranslate == 1"><ww-open-data type='userName'
+                                        :openid='secondCheckerText.name'></ww-open-data></span>
+                                <span v-else>{{ secondCheckerText.name }}</span>
+                            </template>
+                        </van-field>
+                    </div>
                     <van-popup v-model="ownerIdShow" position="bottom" v-if="canExamine" style="height: 90%">
-                        <!-- <div style="minHeight:300px;">
-                            <van-radio-group v-model="userRadio" v-if="user.userNameNeedTranslate == '1'">
-                                <van-radio v-for="item in userList" :key="item.id" :name="item" class="userCheckbox">
-                                    <ww-open-data type='userName' :openid='item.name'></ww-open-data>
-                                </van-radio>
-                            </van-radio-group>
-                            <van-radio-group v-model="userRadio" v-else>
-                                <van-radio v-for="item in userList" :key="item.id" :name="item" class="userCheckbox">{{
-                                    item.name }}</van-radio>
-                            </van-radio-group>
-                            <van-button style="width:100%;position: -webkit-sticky;position: sticky;bottom: 0;"
-                                @click="ownerIdChange()">确定</van-button>
-                        </div> -->
                         <div class="popupDiv paddingTop">
                             <div class="popupCon conBorder">
                                 <van-radio-group v-model="userRadio" v-if="user.userNameNeedTranslate == '1'">
@@ -111,11 +114,23 @@
                                 <template #input>¥{{ getTaxValue(item.amount, item.taxPercent) }}</template>
                             </van-field>
                             <van-field label="备注:" v-model="item.remark" autosize maxlength="100"></van-field>
-                            <van-field label="报销凭证:" @click="invoiceIndex = index" clickable>
+                            <!-- <van-field label="报销凭证:" @click="invoiceIndex = index" clickable>
                                 <template #input>
                                     <van-uploader v-model="uploader[index]" :before-read="beforeRead"
                                         :after-read="afterRead" @delete="item.pic = null" :max-count="1" />
                                 </template>
+                            </van-field> -->
+                            <van-field @click="invoiceIndex = index" clickable label-width="0em">
+                                <template #input>
+                                    <div class="imgListVan">
+                                        <div>报销凭证:</div>
+                                        <div class="vanUploaderImg">
+                                            <van-uploader v-model="uploader[index]" :before-read="beforeRead" multiple
+                                            :after-read="afterRead" @delete="(file, Item) => {deteleImg(file, Item, index)}" :max-count="10" />
+                                        </div>
+                                    </div>
+                                    
+                                </template>
                             </van-field>
                         </div>
                     </div>
@@ -301,6 +316,7 @@ export default {
             },
             userRadio: null,
             ownerIdShow: false,
+            ownerIdShowType: 1, // 1,报销人, 2第一审核人, 3第二审核人
             createDateShow: false,
             typeShow: false,
             typeList: [],
@@ -352,7 +368,9 @@ export default {
             expenseMainType: {
                 text: ''
             },
-            projectSelectVal: ''
+            projectSelectVal: '',
+            firstCheckerText: {},
+            secondCheckerText: {}
         }
     },
     computed: {
@@ -442,8 +460,16 @@ export default {
 
         // #region 费用报销
         ownerIdChange() {
-            this.editForm.ownerId = this.userRadio.id
-            this.formshowText.name = this.userRadio.name
+            if(this.ownerIdShowType == 1) {
+                this.editForm.ownerId = this.userRadio.id
+                this.formshowText.name = this.userRadio.name
+            } else if(this.ownerIdShowType == 2) {
+                this.$set(this.firstCheckerText, 'id', this.userRadio.id)
+                this.$set(this.firstCheckerText, 'name', this.userRadio.name)
+            } else if(this.ownerIdShowType == 3) {
+                this.$set(this.secondCheckerText, 'id', this.userRadio.id)
+                this.$set(this.secondCheckerText, 'name', this.userRadio.name)
+            }
             this.ownerIdShow = false
         },
         createDateChange(value, key) {
@@ -522,24 +548,59 @@ export default {
 
         // 上传报销凭证
         beforeRead(file) {
-            if (file.type != 'image/jpeg' && file.type != 'image/png') {
-                this.$toast.fail('请选择jpg或png格式的图片')
-                return false
+            // console.log(file, file.length)
+            // console.log(Array.isArray(file))
+            // if (file.type != 'image/jpeg' && file.type != 'image/png' && file.type != 'image/jpg') {
+            //     this.$toast.fail('请选择jpg或png格式的图片')
+            //     return false
+            // }
+            // return true
+
+            let newFile = Array.isArray(file) ? file : [file]
+            for(var i in newFile) {
+                const fileItem = newFile[i]
+                if (fileItem.type != 'image/jpeg' && fileItem.type != 'image/png' && fileItem.type != 'image/jpg') {
+                    this.$toast.fail('请选择jpg或png格式的图片')
+                    return false
+                }
             }
             return true
         },
         afterRead(file) {
+            // let formData = new FormData();
+            // formData.append("multipartFile", file.file);
+            // this.$axios.post("/common/uploadFile", formData)
+            //     .then(res => {
+            //         if (res.code == "ok") {
+            //             this.invoiceList[this.invoiceIndex].pic = res.data
+            //         } else {
+            //             this.$toast.fail('上传失败');
+            //             this.uploader[this.invoiceIndex] = []
+            //         }
+            //     }).catch(err => { this.$toast.clear(); console.log(err); this.uploader[this.invoiceIndex] = [] });
+
+            let newFile = Array.isArray(file) ? file : [file]
             let formData = new FormData();
-            formData.append("multipartFile", file.file);
-            this.$axios.post("/common/uploadFile", formData)
-                .then(res => {
-                    if (res.code == "ok") {
-                        this.invoiceList[this.invoiceIndex].pic = res.data
-                    } else {
-                        this.$toast.fail('上传失败');
-                        this.uploader[this.invoiceIndex] = []
-                    }
-                }).catch(err => { this.$toast.clear(); console.log(err); this.uploader[this.invoiceIndex] = [] });
+            for(var i in newFile) {
+                formData.append("multipartFiles", newFile[i].file);
+            }
+            this.$axios.post("/common/uploadFileArray", formData)
+            .then(res => {
+                if (res.code == "ok") {
+                    let newPic = this.invoiceList[this.invoiceIndex].pic || []
+                    let newData = res.data.split(';')
+                    this.invoiceList[this.invoiceIndex].pic = [...newPic, ...newData]
+                    console.log(this.invoiceList[this.invoiceIndex].pic, '<=== 合计图片')
+                } else {
+                    this.$toast.fail('上传失败');
+                    this.uploader[this.invoiceIndex] = []
+                }
+            }).catch(err => { this.$toast.clear(); console.log(err); this.uploader[this.invoiceIndex] = [] });
+        },
+        // 删除图片
+        deteleImg(file, item, arrIndex) {
+            let index = item.index
+            this.invoiceList[arrIndex].pic = this.invoiceList[arrIndex].pic.filter((item,i) => i != index)
         },
 
         // 提交
@@ -552,6 +613,16 @@ export default {
                 this.$toast.fail('请选择填报日期')
                 return
             }
+            if(this.auditTypeItem.auditType == 2) {
+                if(!this.firstCheckerText.id || !this.secondCheckerText.id) {
+                    this.$toast.fail(`${!this.firstCheckerText.id ? '请选择第一审核人' : '请选择第二审核人'}`)
+                    return
+                } else {
+                    this.editForm.firstCheckerId = this.firstCheckerText.id
+                    this.editForm.secondCheckerId = this.secondCheckerText.id
+                }
+            }
+
             let required1 = false
             let required2 = false
             let required3 = false
@@ -591,7 +662,15 @@ export default {
             for (let i in this.invoiceList) {
                 this.invoiceList[i].taxValue = this.getTaxValue(this.invoiceList[i].amount, this.invoiceList[i].taxPercent)
             }
-            this.editForm.items = JSON.stringify(this.invoiceList)
+            
+            let newList = JSON.parse(JSON.stringify(this.invoiceList))
+            for(let i in newList) {
+                if(newList[i].pic) {
+                    newList[i].pic = newList[i].pic.join(',')
+                }
+            }
+            // this.editForm.items = JSON.stringify(this.invoiceList)
+            this.editForm.items = JSON.stringify(newList)
             this.editForm.totalAmount = this.totalCost
             // 获取新的票据编号
             this.confirmLoading = true
@@ -616,6 +695,8 @@ export default {
                                     //     name: '',
                                     //     inProjectName: []
                                     // }
+                                    this.$set(this, 'firstCheckerText', {})
+                                    this.$set(this, 'secondCheckerText', {})
                                     this.formshowText.name = ''
                                     this.formshowText.inProjectName = []
                                     this.expenseMainType.text=''
@@ -803,6 +884,11 @@ export default {
                     this.$toast.fail('获取失败');
                 }
             }).catch(err => { this.$toast.clear(); console.log(err) });
+        },
+        ownerIdShowCli(type) {
+            this.ownerIdShowType = type
+            this.userRadio = ''
+            this.ownerIdShow = true
         }
     },
 }
@@ -849,6 +935,23 @@ export default {
                 text-align: right;
             }
         }
+
+        .imgListVan {
+            display: flex;
+            flex-direction: column;
+        }
+        .vanUploaderImg {
+            // display: flex;
+            margin-top: 6px;
+            /deep/ .van-uploader__preview-image {
+                width: 70px;
+                height: 70px;
+            }
+        }
+        /deep/ .van-uploader__upload {
+            width: 70px;
+            height: 70px;
+        }
     }
 
     .list {