Sfoglia il codice sorgente

Merge branch 'master' of http://git.ycjcjy.com/state_grid/invoice_fill_h5

张延森 2 anni fa
parent
commit
969a3d5a6e
1 ha cambiato i file con 56 aggiunte e 47 eliminazioni
  1. 56
    47
      src/pages/invoice/fill.vue

+ 56
- 47
src/pages/invoice/fill.vue Vedi File

@@ -141,10 +141,10 @@
141 141
 
142 142
 <script setup>
143 143
 import { onMounted, reactive, ref } from 'vue';
144
-import { useRouter } from 'vue-router'
145
-import { Dialog,Toast } from 'vant'
144
+import { useRouter, useRoute } from 'vue-router'
145
+import { Dialog, Toast } from 'vant'
146 146
 import dayjs from 'dayjs'
147
-import { getInvoiceModel, setInvoiceDetail } from '@/services/invoice'
147
+import { getInvoiceModel, setInvoiceDetail, getInvoiceFill } from '@/services/invoice'
148 148
 import { useModel } from '@zjxpcyc/vue-tiny-store'
149 149
 
150 150
 const formData = reactive({
@@ -156,7 +156,6 @@ const formData = reactive({
156 156
   personId: undefined,
157 157
   personName: undefined,
158 158
   orgNameId: undefined,
159
-  endDate: undefined,
160 159
   orgId: undefined,
161 160
   invoiceOrgName: undefined,
162 161
   orgName: undefined,
@@ -178,51 +177,63 @@ const itemList = ref([])
178 177
 const showOrgPicker = ref(false)
179 178
 const showPersonPicker = ref(false)
180 179
 const router = useRouter();
180
+const route = useRoute();
181 181
 const { user } = useModel('user')
182 182
 
183
-// 校验函数返回 true 表示校验通过,false 表示不通过
184
-const validator = (val) => /1\d{10}/.test(val);
185
-
186
-// 校验函数可以直接返回一段错误提示
187
-const validatorMessage = (val) => `${val} 不合法,请重新输入`;
188
-
189 183
 onMounted(() => {
190 184
   //不是扫码进入
191
-  if (!router.currentRoute._rawValue.params.invoiceId) {
185
+  if (!route.query.invoiceId) {
192 186
     Dialog.alert({
193 187
       message: '请退出页面重新扫码进入'
194 188
     }).then(() => { })
195 189
     formData.isFinished = ture
196 190
     return
197 191
   }
198
-  //过期
199
-  let endDate = router.currentRoute._rawValue.params.endDate
200
-  if (dayjs().isAfter(dayjs(endDate))) {
201
-    formData.isFinished = true
202
-    Dialog.alert({
203
-      message: '该班次已截止如有问题请联系报销助理'
204
-    }).then(() => { })
205
-  }
206
-  formData.invoiceId = router.currentRoute._rawValue.params.invoiceId
207
-  formData.invoiceName = router.currentRoute._rawValue.params.invoiceName
192
+  getInvoiceFill(route.query.invoiceId).then(res => {
193
+    //过期
194
+    if (dayjs().isAfter(dayjs(res.endDate) || res.status == 2)) {
195
+      formData.isFinished = true
196
+      Dialog.alert({
197
+        message: '该班次已截止如有问题请联系报销助理'
198
+      })
199
+      formData.invoiceName = res.name
200
+    } else {
201
+
202
+      getInvoiceModel(route.query.invoiceId, { invoicePersonId: formData.invoicePersonId, personId: user.value.personId }).then(val => {
203
+        const info = {
204
+          ...(val.detail || val.tpl),
205
+          invoiceName: res.name
206
+        }
207
+        Object.assign(formData, info)
208
+        itemList.value = info.itemList
209
+      }).catch(err => {
210
+        console.log(err);
211
+      })
212
+    }
213
+  }).catch(err => {
214
+    console.log(err)
215
+  })
216
+
217
+
218
+
219
+
220
+
208 221
   formData.status = router.currentRoute._rawValue.params.status
209
-  formData.endDate = endDate
210 222
   formData.mergeRemark = '否'
211
-})
212 223
 
213
-// 校验函数可以返回 Promise,实现异步校验
214
-const asyncValidator = (val) =>
215
-  new Promise((resolve) => {
216
-    Toast.loading('验证中...');
217
-    setTimeout(() => {
218
-      Toast.clear();
219
-      resolve(val === '1234');
220
-    }, 1000);
221
-  });
224
+})
222 225
 
223 226
 const onFailed = (errorInfo) => {
224 227
   console.log('failed', formData);
225 228
 };
229
+
230
+//选择企业
231
+const changeOrg = () => {
232
+  if (!formData.isFinished) {
233
+    showOrgPicker.value = true
234
+  }
235
+}
236
+//确认企业
226 237
 const onOrgConfirm = (value) => {
227 238
   if (value) {
228 239
     formData.orgId = value.invoiceOrgId
@@ -232,11 +243,7 @@ const onOrgConfirm = (value) => {
232 243
   }
233 244
   showOrgPicker.value = false;
234 245
 };
235
-const changeOrg = () => {
236
-  if (!formData.isFinished) {
237
-    showOrgPicker.value = true
238
-  }
239
-}
246
+//选择报销人
240 247
 const showOrgPopup = () => {
241 248
   if (!formData.isFinished) {
242 249
     if (formData.orgId) {
@@ -248,6 +255,16 @@ const showOrgPopup = () => {
248 255
     }
249 256
   }
250 257
 }
258
+//确认报销人
259
+const onPersonConfirm = (value) => {
260
+  if (value) {
261
+    console.log(value);
262
+    formData.personName = value.name
263
+    formData.invoicePersonId = value.invoicePersonId
264
+    getDetail()
265
+  }
266
+  showPersonPicker.value = false;
267
+};
251 268
 //获取模板详情
252 269
 const getDetail = () => {
253 270
   getInvoiceModel(formData.invoiceId, { invoicePersonId: formData.invoicePersonId, personId: user.value.personId }).then(res => {
@@ -264,17 +281,8 @@ const getDetail = () => {
264 281
     console.log(err);
265 282
   })
266 283
 }
267
-const onPersonConfirm = (value) => {
268
-  if (value) {
269
-    console.log(value);
270
-    formData.personName = value.name
271
-    formData.invoicePersonId = value.invoicePersonId
272
-    getDetail()
273
-  }
274
-  showPersonPicker.value = false;
275
-};
284
+//提交表单
276 285
 const onSubmit = (val) => {
277
-  console.log(formData);
278 286
   if (itemList.value.length == 0) {
279 287
     Dialog.alert({
280 288
       message: '未找到报销项目请联系报销专员'
@@ -290,6 +298,7 @@ const onSubmit = (val) => {
290 298
     console.log(err);
291 299
   })
292 300
 }
301
+
293 302
 </script>
294 303
 <style lang="less" scoped>
295 304
 .lastLine::after {