李志伟 2 years ago
parent
commit
bd25189a0b
6 changed files with 156 additions and 53 deletions
  1. 1
    0
      package.json
  2. 2
    1
      src/pages/index.vue
  3. 131
    48
      src/pages/invoice/fill.vue
  4. 12
    4
      src/services/invoice.js
  5. 5
    0
      src/vant.js
  6. 5
    0
      yarn.lock

+ 1
- 0
package.json View File

11
     "@zjxpcyc/vue-tiny-store": "^1.0.1",
11
     "@zjxpcyc/vue-tiny-store": "^1.0.1",
12
     "axios": "^0.27.2",
12
     "axios": "^0.27.2",
13
     "crypto-js": "^4.1.1",
13
     "crypto-js": "^4.1.1",
14
+    "dayjs": "^1.11.3",
14
     "nprogress": "^0.2.0",
15
     "nprogress": "^0.2.0",
15
     "vant": "^3.5.2",
16
     "vant": "^3.5.2",
16
     "vue": "^3.2.25",
17
     "vue": "^3.2.25",

+ 2
- 1
src/pages/index.vue View File

46
 const formData = reactive({
46
 const formData = reactive({
47
   data: {
47
   data: {
48
     //班级名称
48
     //班级名称
49
-    invoiceId: 'f11ab8d28fd097e7aa4877ae7068a876',
49
+    invoiceId: 'e288229edfd3cdd2eaac125b65eca10e',
50
     endDate: undefined,
50
     endDate: undefined,
51
     name: undefined,
51
     name: undefined,
52
     status: 1
52
     status: 1
58
   params: { 
58
   params: { 
59
     invoiceId: formData.data.invoiceId,
59
     invoiceId: formData.data.invoiceId,
60
     invoiceName: formData.data.name,
60
     invoiceName: formData.data.name,
61
+    endDate:formData.data.endDate,
61
     status:formData.data.status
62
     status:formData.data.status
62
   } })
63
   } })
63
 }
64
 }

+ 131
- 48
src/pages/invoice/fill.vue View File

1
 <template>
1
 <template>
2
-  <van-form @failed="onFailed" @submit="onSubmit">
2
+  <van-form
3
+    @failed="onFailed"
4
+    @submit="onSubmit"
5
+    :readonly="formData.isFinished"
6
+  >
3
     <h2 :style="{ textAlign: 'center' }">{{ formData.invoiceName }}</h2>
7
     <h2 :style="{ textAlign: 'center' }">{{ formData.invoiceName }}</h2>
4
     <van-cell-group title="报销人信息">
8
     <van-cell-group title="报销人信息">
5
       <van-field
9
       <van-field
7
         v-model="formData.invoiceOrgName"
11
         v-model="formData.invoiceOrgName"
8
         name="invoiceOrgName"
12
         name="invoiceOrgName"
9
         readonly
13
         readonly
10
-        @click="showOrgPicker = true"
14
+        @click="changeOrg"
11
         placeholder="请输入所属公司"
15
         placeholder="请输入所属公司"
12
         :rules="[{ required: true, message: '请输入所属公司' }]"
16
         :rules="[{ required: true, message: '请输入所属公司' }]"
13
       />
17
       />
88
         placeholder="请输入开户行账号"
92
         placeholder="请输入开户行账号"
89
         :rules="[{ required: true, message: '请输入开户行账号' }]"
93
         :rules="[{ required: true, message: '请输入开户行账号' }]"
90
       />
94
       />
91
-    </van-cell-group>
92
-
93
-    <van-cell-group title="报销信息">
94
-      <van-cell title="报销项目">
95
-        <template #value>
96
-          <span style="color: #000">培训费</span>
97
-        </template>
98
-      </van-cell>
99
-      <van-cell title="开票金额">
100
-        <template #value>
101
-          <span style="color: #f00">600.00</span>
102
-        </template>
103
-      </van-cell>
104
-      <van-cell title="报销项目">
105
-        <template #value>
106
-          <span style="color: #000">住宿费</span>
107
-        </template>
108
-      </van-cell>
109
-      <van-cell title="开票金额">
110
-        <template #value>
111
-          <span style="color: #f00">1200.00</span>
112
-        </template>
113
-      </van-cell>
114
-      <van-cell title="报销项目">
115
-        <template #value>
116
-          <span style="color: #000">餐费</span>
117
-        </template>
118
-      </van-cell>
119
-      <van-cell title="开票金额">
120
-        <template #value>
121
-          <span style="color: #f00">600.00</span>
95
+      <van-field
96
+        name="radio"
97
+        label="是否合开"
98
+        error-message="如果合开请和报销专员联系"
99
+      >
100
+        <template #input>
101
+          <van-radio-group
102
+            v-model="formData.mergeRemark"
103
+            direction="horizontal"
104
+            :disabled="formData.isFinished"
105
+          >
106
+            <van-radio name="是">是</van-radio>
107
+            <van-radio name="否">否</van-radio>
108
+          </van-radio-group>
122
         </template>
109
         </template>
123
-      </van-cell>
110
+      </van-field>
124
     </van-cell-group>
111
     </van-cell-group>
125
 
112
 
113
+    <van-cell-group v-if="itemList.length != 0" title="报销信息">
114
+      <div class="itembox" v-for="item in itemList" :key="item.invoiceItemId">
115
+        <van-cell title="报销项目">
116
+          <template #value>
117
+            <span style="color: #000">{{ item.name }}</span>
118
+          </template>
119
+        </van-cell>
120
+        <van-cell title="开票金额">
121
+          <template #value>
122
+            <span style="color: #000">{{ item.charge }}</span>
123
+          </template>
124
+        </van-cell>
125
+        <div class="lastLine" />
126
+      </div>
127
+    </van-cell-group>
126
     <div style="margin: 16px">
128
     <div style="margin: 16px">
127
-      <van-button round block type="primary" native-type="submit">
129
+      <van-button
130
+        v-show="!formData.isFinished"
131
+        round
132
+        block
133
+        type="primary"
134
+        native-type="submit"
135
+      >
128
         提交
136
         提交
129
       </van-button>
137
       </van-button>
130
     </div>
138
     </div>
134
 <script setup>
142
 <script setup>
135
 import { onMounted, reactive, ref } from 'vue';
143
 import { onMounted, reactive, ref } from 'vue';
136
 import { useRouter } from 'vue-router'
144
 import { useRouter } from 'vue-router'
137
-import { getInvoiceModel } from '@/services/invoice'
145
+import { Dialog,Toast } from 'vant'
146
+import dayjs from 'dayjs'
147
+import { getInvoiceModel, setInvoiceDetail } from '@/services/invoice'
148
+import { useModel } from '@zjxpcyc/vue-tiny-store'
138
 
149
 
139
 const formData = reactive({
150
 const formData = reactive({
140
   //班级名称
151
   //班级名称
145
   personId: undefined,
156
   personId: undefined,
146
   personName: undefined,
157
   personName: undefined,
147
   orgNameId: undefined,
158
   orgNameId: undefined,
159
+  endDate: undefined,
148
   orgId: undefined,
160
   orgId: undefined,
149
   invoiceOrgName: undefined,
161
   invoiceOrgName: undefined,
150
   orgName: undefined,
162
   orgName: undefined,
157
   invoiceItemTplId: undefined,
169
   invoiceItemTplId: undefined,
158
   itemName: undefined,
170
   itemName: undefined,
159
   charge: undefined,
171
   charge: undefined,
160
-  mergeRemark: undefined,
161
-  stayRemark: undefined,
172
+  //是否结束
173
+  isFinished: false,
174
+  mergeRemark: '否',
162
   status: undefined
175
   status: undefined
163
 })
176
 })
177
+const itemList = ref([])
164
 const showOrgPicker = ref(false)
178
 const showOrgPicker = ref(false)
165
 const showPersonPicker = ref(false)
179
 const showPersonPicker = ref(false)
166
 const router = useRouter();
180
 const router = useRouter();
181
+const { user } = useModel('user')
167
 
182
 
168
 // 校验函数返回 true 表示校验通过,false 表示不通过
183
 // 校验函数返回 true 表示校验通过,false 表示不通过
169
 const validator = (val) => /1\d{10}/.test(val);
184
 const validator = (val) => /1\d{10}/.test(val);
172
 const validatorMessage = (val) => `${val} 不合法,请重新输入`;
187
 const validatorMessage = (val) => `${val} 不合法,请重新输入`;
173
 
188
 
174
 onMounted(() => {
189
 onMounted(() => {
190
+  //不是扫码进入
191
+  if (!router.currentRoute._rawValue.params.invoiceId) {
192
+    Dialog.alert({
193
+      message: '请退出页面重新扫码进入'
194
+    }).then(() => { })
195
+    formData.isFinished = ture
196
+    return
197
+  }
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
+  }
175
   formData.invoiceId = router.currentRoute._rawValue.params.invoiceId
206
   formData.invoiceId = router.currentRoute._rawValue.params.invoiceId
176
   formData.invoiceName = router.currentRoute._rawValue.params.invoiceName
207
   formData.invoiceName = router.currentRoute._rawValue.params.invoiceName
177
   formData.status = router.currentRoute._rawValue.params.status
208
   formData.status = router.currentRoute._rawValue.params.status
209
+  formData.endDate = endDate
210
+  formData.mergeRemark = '否'
178
 })
211
 })
179
 
212
 
180
 // 校验函数可以返回 Promise,实现异步校验
213
 // 校验函数可以返回 Promise,实现异步校验
195
     formData.orgId = value.invoiceOrgId
228
     formData.orgId = value.invoiceOrgId
196
     formData.invoiceOrgName = value.name
229
     formData.invoiceOrgName = value.name
197
     formData.personName = ''
230
     formData.personName = ''
198
-    formData.invoicePersonId=''
231
+    formData.invoicePersonId = ''
199
   }
232
   }
200
   showOrgPicker.value = false;
233
   showOrgPicker.value = false;
201
 };
234
 };
235
+const changeOrg = () => {
236
+  if (!formData.isFinished) {
237
+    showOrgPicker.value = true
238
+  }
239
+}
202
 const showOrgPopup = () => {
240
 const showOrgPopup = () => {
203
-  if (formData.orgId) {
204
-    showPersonPicker.value = true
205
-  } else {
206
-    alert('请先选择所属公司')
241
+  if (!formData.isFinished) {
242
+    if (formData.orgId) {
243
+      showPersonPicker.value = true
244
+    } else {
245
+      Dialog.alert({
246
+        message: '请先选择所属公司'
247
+      }).then(() => { })
248
+    }
207
   }
249
   }
208
 }
250
 }
209
 //获取模板详情
251
 //获取模板详情
210
 const getDetail = () => {
252
 const getDetail = () => {
211
-  getInvoiceModel(formData.invoiceId, { invoicePersonId: formData.invoicePersonId,personId:formData.invoicePersonId }).then(res => {
212
-    console.log(res)
253
+  getInvoiceModel(formData.invoiceId, { invoicePersonId: formData.invoicePersonId, personId: user.value.personId }).then(res => {
254
+    const info = {
255
+      ...(res.detail || res.tpl),
256
+      invoicePersonId: formData.invoicePersonId,
257
+      personName: formData.personName,
258
+      orgId: formData.orgId,
259
+      invoiceOrgName: formData.invoiceOrgName
260
+    }
261
+    Object.assign(formData, info)
262
+    itemList.value = info.itemList
213
   }).catch(err => {
263
   }).catch(err => {
214
     console.log(err);
264
     console.log(err);
215
   })
265
   })
218
   if (value) {
268
   if (value) {
219
     console.log(value);
269
     console.log(value);
220
     formData.personName = value.name
270
     formData.personName = value.name
221
-    formData.invoicePersonId= value.invoicePersonId
271
+    formData.invoicePersonId = value.invoicePersonId
222
     getDetail()
272
     getDetail()
223
   }
273
   }
224
   showPersonPicker.value = false;
274
   showPersonPicker.value = false;
225
 };
275
 };
226
 const onSubmit = (val) => {
276
 const onSubmit = (val) => {
227
-  console.info(formData)
277
+  console.log(formData);
278
+  if (itemList.value.length == 0) {
279
+    Dialog.alert({
280
+      message: '未找到报销项目请联系报销专员'
281
+    }).then(() => { })
282
+    return;
283
+  }
284
+  setInvoiceDetail(formData.invoiceId, formData).then(() => {
285
+    Toast.success('提交成功');
286
+    setTimeout(() => {
287
+      router.back()
288
+    }, 1000);
289
+  }).catch(err => {
290
+    console.log(err);
291
+  })
292
+}
293
+</script>
294
+<style lang="less" scoped>
295
+.lastLine::after {
296
+  position: absolute;
297
+  box-sizing: border-box;
298
+  content: " ";
299
+  pointer-events: none;
300
+  right: var(--van-padding-md);
301
+  bottom: 0;
302
+  left: var(--van-padding-md);
303
+  border-bottom: 1px solid var(--van-cell-border-color);
304
+  transform: scaleY(0.5);
305
+}
306
+.cellClassName {
307
+  .van-cell__value {
308
+    min-width: 80% !important; //可根据自己需求设定值
309
+    text-align: left !important;
310
+  }
228
 }
311
 }
229
-</script>
312
+</style>

+ 12
- 4
src/services/invoice.js View File

2
 
2
 
3
 // 获取班级详情
3
 // 获取班级详情
4
 export function getInvoiceFill(id) {
4
 export function getInvoiceFill(id) {
5
-  return request.get(`/invoice/${id}`)
5
+  return request.get(`/invoice/${id}`);
6
 }
6
 }
7
 
7
 
8
 // 获取报销模板详情
8
 // 获取报销模板详情
9
-export function getInvoiceModel(id,params) {
10
-  return request.get(`/invoice/${id}/detail/info`,{params})
11
-}
9
+export function getInvoiceModel(id, params) {
10
+  return request.get(`/invoice/${id}/detail/info`, { params });
11
+}
12
+
13
+/**
14
+ * 生成报销明细
15
+ * @param
16
+ * @returns
17
+ */
18
+export const setInvoiceDetail = (id, data) =>
19
+  request(`/invoice/${id}/detail`, { method: "put", data });

+ 5
- 0
src/vant.js View File

13
   ImagePreview,
13
   ImagePreview,
14
   Search,
14
   Search,
15
   Toast,
15
   Toast,
16
+  Radio,
17
+  RadioGroup,
16
   Popup
18
   Popup
17
 } from 'vant';
19
 } from 'vant';
18
 
20
 
22
 import 'vant/es/image-preview/style';
24
 import 'vant/es/image-preview/style';
23
 
25
 
24
 export default function vant(app) {
26
 export default function vant(app) {
27
+  //use包裹起来是全局注册是给标签用的如果是给setup 语法用要在需要的页面引用一下
25
   app.use(Button);
28
   app.use(Button);
26
   app.use(Cell);
29
   app.use(Cell);
27
   app.use(CellGroup);
30
   app.use(CellGroup);
36
   app.use(Search);
39
   app.use(Search);
37
   app.use(Toast);
40
   app.use(Toast);
38
   app.use(Popup);
41
   app.use(Popup);
42
+  app.use(Radio);
43
+  app.use(RadioGroup);
39
 }
44
 }

+ 5
- 0
yarn.lock View File

257
   resolved "https://registry.npmmirror.com/csstype/-/csstype-2.6.20.tgz#9229c65ea0b260cf4d3d997cb06288e36a8d6dda"
257
   resolved "https://registry.npmmirror.com/csstype/-/csstype-2.6.20.tgz#9229c65ea0b260cf4d3d997cb06288e36a8d6dda"
258
   integrity sha512-/WwNkdXfckNgw6S5R125rrW8ez139lBHWouiBvX8dfMFtcn6V81REDqnH7+CRpRipfYlyU1CmOnOxrmGcFOjeA==
258
   integrity sha512-/WwNkdXfckNgw6S5R125rrW8ez139lBHWouiBvX8dfMFtcn6V81REDqnH7+CRpRipfYlyU1CmOnOxrmGcFOjeA==
259
 
259
 
260
+dayjs@^1.11.3:
261
+  version "1.11.3"
262
+  resolved "https://registry.npmmirror.com/dayjs/-/dayjs-1.11.3.tgz#4754eb694a624057b9ad2224b67b15d552589258"
263
+  integrity sha512-xxwlswWOlGhzgQ4TKzASQkUhqERI3egRNqgV4ScR8wlANA/A9tZ7miXa44vTTKEq5l7vWoL5G57bG3zA+Kow0A==
264
+
260
 debug@^3.2.6:
265
 debug@^3.2.6:
261
   version "3.2.7"
266
   version "3.2.7"
262
   resolved "https://registry.npmmirror.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a"
267
   resolved "https://registry.npmmirror.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a"