From ea44321752674bc97efb7bfa987c19121c3d6881 Mon Sep 17 00:00:00 2001 From: zhangwei <1504152376@qq.com> Date: 星期四, 16 一月 2025 17:16:50 +0800 Subject: [PATCH] 财务报销(未完成) --- src/pages/reimbursement/index.vue | 397 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 397 insertions(+), 0 deletions(-) diff --git a/src/pages/reimbursement/index.vue b/src/pages/reimbursement/index.vue new file mode 100644 index 0000000..6505065 --- /dev/null +++ b/src/pages/reimbursement/index.vue @@ -0,0 +1,397 @@ +<template> + <view class="full-page "> + <view class="list"> + <up-form labelPosition="left" :model="state.publicJob" ref="formRef" labelWidth='140rpx'> + <view class="content c-p-l-24 c-p-b-120"> + <up-form-item label="閮ㄩ棬" prop="departmentId" required :borderBottom='false' ref="item1"> + <up-input v-model="state.publicJob.departmentName" border="none" placeholder="璇风偣鍑婚�夋嫨閮ㄩ棬" + readonly></up-input> + </up-form-item> + <up-form-item label="濮撳悕" prop="name" required :borderBottom='false' ref="item1"> + <up-input v-model="state.publicJob.name" border="none" placeholder="璇峰~鍐欏鍚�" readonly></up-input> + </up-form-item> + <up-form-item label="閲戦" prop="planMoney" required :borderBottom='false' ref="item1"> + <up-input v-model="state.publicJob.planMoney" border="none" placeholder="璇峰~鍐欓噾棰�" + type="digit"></up-input> + </up-form-item> + <up-form-item label="绉戠洰" prop="rewardContent" required :borderBottom='false' ref="item1" + @click='openKemuPicker'> + <up-input v-model="state.publicJob.rewardContent" border="none" placeholder="璇风偣鍑婚�夋嫨绉戠洰" + readonly></up-input> + </up-form-item> + <up-form-item label="鎽樿" prop="planContent" required :borderBottom='false' ref="item1"> + <view class="c-p-b-20"> + <up-textarea v-model="state.publicJob.planContent" border="none" placeholder="璇峰~鍐欐憳瑕�" count + maxlength='200'></up-textarea> + </view> + </up-form-item> + <up-form-item label="鍙戠エ" prop="houbufapiaoStatus" required :borderBottom='false' ref="item1"> + <u-radio-group v-model="state.publicJob.houbufapiaoStatus" placement="row" + @change="checkboxChange"> + <u-radio :customStyle="{marginBottom: '8px',marginRight:'8px'}" label="鏈夊彂绁�" name="You" + usedAlone /> + <u-radio :customStyle="{marginBottom: '8px',marginRight:'8px'}" label="鍊欒ˉ鍙戠エ" + name="HouBuFaPiao" usedAlone /> + <u-radio :customStyle="{marginBottom: '8px'}" label="娌″彂绁�" name="Wu" usedAlone /> + </u-radio-group> + </up-form-item> + <up-form-item label="涓婁紶鍙戠エ" prop="idCardFace" required + v-if='state.publicJob.houbufapiaoStatus!=="Wu"'> + <fui-upload immediate :url="`${apiBaseUrl}/api/UpFile/UpdateFile`" ref="uploadF" + @success="success('Invoice',$event)" @error="errorInvoice" + @complete="completeInvoice('Invoice',$event)"> + </fui-upload> + </up-form-item> + <up-form-item label="涓婁紶闄勪欢" prop="idCardFace"> + <tem-upload-file immediate :url="`${apiBaseUrl}/api/UpFile/UpdateFile`" ref="uploadB" + @success="success('File',$event)" @error="errorInvoice" + @complete="completeInvoice('',$event)"> + </tem-upload-file> + </up-form-item> + </view> + </up-form> + </view> + <view class="tabbtns"> + <view class="chuany-flex"> + <up-button color='#fece01' class="text-69" :text="'缁х画鎶ラ攢'" :loading='isLoading' :loadingText="'鎻愪氦涓�'" + @click="saveOrder('continue')"></up-button> + <up-button color='#fece01' class="text-69" :text="planId?'淇敼鎶ラ攢':'鎻愪氦鎶ラ攢'" :loading='isLoading' + :loadingText="planId?'淇敼涓�':'鎻愪氦涓�'" @click="saveOrder"></up-button> + </view> + + </view> + <!-- <u-picker :show="pickerShow" :columns="departList" keyName="name" @cancel='openPicker' + :defaultIndex='defaultIndex' @confirm='confirmPicker'></u-picker> --> + <u-picker :show="kemuPicker" :columns="kemuList" keyName="subjectName" @cancel='openKemuPicker' + :defaultIndex='defaultIndex' @confirm='confirmKemuPicker'></u-picker> + + </view> +</template> + +<script setup> + import { + apiBaseUrl + } from '@/common/setting/constVarsHelper.js'; + import { + ref, + reactive, + getCurrentInstance, + onMounted, + computed + } from 'vue'; + import { + onLoad, + onShow, + onReady, + onHide + } from "@dcloudio/uni-app"; + const { + $upload, + $api, + $util, + $db + } = getCurrentInstance().appContext.config.globalProperties + import { + useStore + } from 'vuex' + const store = useStore() + let departList = ref() + let kemuList = ref() + let defaultIndex = ref([6]) + let planId = ref('') + let state = reactive({ + publicJob: { + departmentId: '', //閮ㄩ棬Id + departmentName: '', + name: '', //濮撳悕 + rewardResult: '', //绉戠洰id + rewardContent: '', //绉戠洰鍚嶇О + planMoney: '', //閲戦 + planContent: '', //鎽樿 + houbufapiaoStatus: 'You', //鏈夋棤鍙戠エ + workPlanAttachments: [] //闄勪欢&鍙戠エ + }, + }) + onLoad((options) => { + let data = $db.get('userInfo').userCompany + planId.value = options.planId + if (!planId.value) { + state.publicJob.departmentId = $db.get('userInfo').oaPermissions.departId + state.publicJob.departmentName = $db.get('userInfo').oaPermissions.departmentName + state.publicJob.name = $db.get('userInfo').oaPermissions.name + } + // $api.GetDepartLstt().then(res => { + // departList = [res.data] + // let index = res.data.findIndex(item => { + // return item.keyid == planId.value ? state.publicJob.departmentId : oaPermissions.departId + // }) + // defaultIndex = [index] + // }) + $api.getKeMuList().then(res => { + kemuList = [res.data] + dataPlan(planId.value) + }) + }) + let rules = { + name: { + required: true, + message: '濮撳悕涓嶈兘涓虹┖', + trigger: ['blur', 'change'] + }, + departId: { + required: true, + message: '閮ㄩ棬涓嶈兘涓虹┖', + trigger: ['blur', 'change'] + }, + planMoney: { + required: true, + message: '閲戦涓嶈兘涓虹┖', + trigger: ['blur', 'change'] + }, + planContent: { + required: true, + message: '鎽樿涓嶈兘涓虹┖', + trigger: ['blur', 'change'] + }, + rewardContent: { + required: true, + message: '绉戠洰涓嶈兘涓虹┖', + trigger: ['blur', 'change'] + } + } + const formRef = ref(null); + onReady(() => { + formRef.value.setRules(rules); + }) + onShow(() => { + console.log('Show-------------', state.publicJob); + }) + onMounted(() => { + formRef.value.setRules(rules); + console.log(formRef.value, 'formRef'); // 璁块棶瀛愮粍浠禗emo涓殑灞炴�� + + }); + let oaPermissions = computed(() => store.getters.userInfo.oaPermissions || {}) + let dateType = ref() + let minDate = $util.formatDate(new Date()) + let sDate = $util.formatDate(new Date(), null, 1) + let eDate = '缁撴潫鏃ユ湡' + let workDate = ref('') + let workTime = ref('8:00鑷�18:00') + let datePickerShow = ref(false) + let pickerShow = ref(false) + let kemuPicker = ref(false) + let isLoading = ref(false) + let editItem = null + let uploadF = ref() + let uploadB = ref() + + const changStyle = (val) => { + state.publicJob.workerType = val + if (val == 0) { + state.publicJob.zixinganpai = false + } + } + const dataPlan = (planId) => { + if (planId) { + $api.workerGetPlanInfo(planId).then(res => { + state.publicJob = { + keyid: res.data.keyid, + departmentId: res.data.departId, //閮ㄩ棬Id + departmentName: $db.get('userInfo').oaPermissions.departmentName, + name: res.data.planPeople, //濮撳悕 + rewardResult: res.data.rewardResult, //绉戠洰id + rewardContent: res.data.rewardContent, //绉戠洰鍚嶇О + planMoney: String(res.data.planMoney), //閲戦 + planContent: res.data.planContent, //鎽樿 + houbufapiaoStatus: res.data.houbufapiaoStatus, //鏈夋棤鍙戠エ + workPlanAttachments: res.data.workPlanAttachments //闄勪欢&鍙戠エ + } + state.publicJob.workPlanAttachments.forEach(item => { + if (item.attachmentType == 1) { + uploadF.value.urls.push(item.planAttachment) + uploadF.value.status.push('success') + } else { + uploadB.value.urls.push(item.planAttachment) + uploadB.value.status.push('success') + } + }) + let index = kemuList[0].findIndex(item => { + return item.keyid == state.publicJob.rewardResult + }) + defaultIndex = [index] + console.log(state.publicJob); + }) + + // state.publicJob = reactive(editItem) + // $db.del('editItem') + } + } + const confirmPicker = (arr) => { + state.publicJob.departmentId = arr.value[0].keyid + state.publicJob.departmentName = arr.value[0].name + openPicker() + } + const confirmKemuPicker = (arr) => { + state.publicJob.rewardResult = String(arr.value[0].keyid) + state.publicJob.rewardContent = arr.value[0].subjectName + openKemuPicker() + } + const clickTime = (type) => { + dateType.value = type + datePickerShow.value = !datePickerShow.value + } + const cancel = () => { + datePickerShow.value = !datePickerShow.value + } + const openPicker = () => { + pickerShow.value = !pickerShow.value + } + const openKemuPicker = () => { + kemuPicker.value = !kemuPicker.value + } + const checkboxChange = () => { + + } + const saveOrder = (val) => { + if (state.publicJob.houbufapiaoStatus == "You") { + let index = state.publicJob.workPlanAttachments.findIndex(item => { + return item.attachmentType == 1 + }) + if (index == -1) { + $util.showToast({ + title: "閫夋嫨鏈夊彂绁ㄦ椂锛屽繀椤讳笂浼犲彂绁紒", + }) + return + } + + } + formRef.value.validate().then(res => { + isLoading.value = true + let functionOrder = null + if (planId.value) { + functionOrder = $api.EditOder + } else { + functionOrder = $api.CreatOder + } + functionOrder(state.publicJob).then(res => { + if (res.code == 1) { + if (editItem) { + uni.navigateBack() + } else if (val == 'continue') { + state.publicJob = { + departmentId: $db.get('userInfo').oaPermissions.departId, //閮ㄩ棬Id + departmentName: $db.get('userInfo').oaPermissions.departmentName, + name: $db.get('userInfo').oaPermissions.name, //濮撳悕 + rewardResult: '', //绉戠洰id + rewardContent: '', //绉戠洰鍚嶇О + planMoney: '', //閲戦 + planContent: '', //鎽樿 + houbufapiaoStatus: 'You', //鏈夋棤鍙戠エ + workPlanAttachments: [], //闄勪欢&鍙戠エ + } + uploadB.value.urls = [] + uploadB.value.status = [] + uploadF.value.urls = [] + uploadF.value.status = [] + } else { + uni.navigateTo({ + url: '/pages/reimbursement/myreim' + }) + } + $util.showToast({ + title: editItem ? '淇敼鎴愬姛锛�' : "淇濆瓨鎴愬姛锛�", + icon: "success" + }) + } else { + $util.showToast({ + title: res.error + }) + } + isLoading.value = false + }) + }) + } + //閫夋嫨鍥剧墖鎴栦笂浼犲畬鎴愭椂瑙﹀彂 + const completeInvoice = (val, e) => { + if (e.action == 'delete') { + // 鍒犻櫎澶勭悊 + state.publicJob.workPlanAttachments = state.publicJob.workPlanAttachments.filter(item => { + return item.attachmentType == (val == "Invoice" ? 2 : 1) + }) + e.urls.forEach(item => { + let obj = {} + obj.attachmentType = val == "Invoice" ? 1 : 2 + obj.planAttachment = item //鍙戠エ + state.publicJob.workPlanAttachments.push(obj) + }) + return + } + // $util.pathToBase64(e.urls[0]).then(res => { + // idCardFaceBase64.value = res + // console.log(idCardFaceBase64, idCardFaceBase64.value); + // }) + } + const errorInvoice = (e) => { + console.log(e, '--------------'); + } + //涓婁紶鎴愬姛鏃惰Е鍙� + const success = (text, e) => { + let obj = {} + //e.res 涓烘湇鍔″櫒杩斿洖鏁版嵁 + //涓婁紶鎴愬姛鍥炶皟锛屽鐞嗘湇鍔″櫒杩斿洖鏁版嵁銆愭澶勬牴鎹疄闄呰繑鍥炴暟鎹繘琛屽鐞嗐�� + let res = JSON.parse(e.res.data.replace(/\ufeff/g, "") || "{}") + if (res.code == 1) { + if (res.data && text == 'Invoice') { + obj.attachmentType = 1 + obj.planAttachment = res.data //鍙戠エ + uploadF.value.urls.push(res.data) + uploadF.value.urls = uploadF.value.urls.filter(item => { + return item.indexOf('https') !== -1 + }) + uploadF.value.status.push('success') + uploadF.value.status.length = uploadF.value.urls.length + } else { + obj.attachmentType = 2 + obj.planAttachment = res.data //闄勪欢 + uploadB.value.urls.push(res.data) + uploadB.value.urls = uploadB.value.urls.filter(item => { + return item.indexOf('https') !== -1 + }) + uploadB.value.status.push('success') + uploadB.value.status.length = uploadB.value.urls.length + } + state.publicJob.workPlanAttachments.push(obj) + } else { + uni.$u.toast(res.error) + if (text == 'Invoice') { + uploadF.value.deleteImage() + } else { + uploadB.value.deleteImage() + } + } + + } +</script> + +<style> + .list {} + + .u-button { + width: 280rpx !important; + margin: 0; + } + + .content { + width: 100%; + box-sizing: border-box; + background-color: #fff; + } + + .u-textarea { + padding: 0 !important; + } + .u-form-item__body { + padding: 5px 0 !important; + } +</style> \ No newline at end of file -- Gitblit v1.9.1