李志伟 2 years ago
parent
commit
b7e7e3c0a0

+ 7
- 0
src/pages/invoice/components/DetailInfo.vue View File

@@ -0,0 +1,7 @@
1
+<template>
2
+<div></div>
3
+</template>
4
+<script>
5
+</script>
6
+<style>
7
+</style>

+ 0
- 0
src/pages/invoice/components/ItemTpl.vue View File


+ 109
- 0
src/pages/invoice/components/PersonInfo.vue View File

@@ -0,0 +1,109 @@
1
+<template>
2
+  <van-cell-group title="报销人信息">
3
+    <van-field
4
+      label="所属公司"
5
+      v-model="data.invoiceOrgName"
6
+      name="invoiceOrgName"
7
+      readonly
8
+      @click="changeOrg"
9
+      placeholder="请输入所属公司"
10
+      :rules="[{ required: true, message: '请输入所属公司' }]"
11
+    />
12
+    <van-popup
13
+      v-model:show="showOrgPicker"
14
+      position="left"
15
+      :style="{ height: '100%', width: '80%' }"
16
+    >
17
+      <org-picker
18
+        v-model="data.invoiceOrgId"
19
+        :invoiceId="invoiceId"
20
+        @change="onOrgConfirm"
21
+      />
22
+    </van-popup>
23
+    <van-field
24
+      label="报销人"
25
+      v-model="data.personName"
26
+      name="personName"
27
+      readonly
28
+      @click="showOrgPopup"
29
+      placeholder="请输入报销人"
30
+      :rules="[{ required: true, message: '请输入报销人' }]"
31
+    />
32
+    <van-popup
33
+      v-model:show="showPersonPicker"
34
+      position="left"
35
+      :style="{ height: '100%', width: '80%' }"
36
+    >
37
+      <person-picker
38
+        v-model="data.personId"
39
+        :invoiceId="invoiceId"
40
+        :orgId="formData.invoiceOrgId"
41
+        @change="onPersonConfirm"
42
+      />
43
+    </van-popup>
44
+  </van-cell-group>
45
+</template>
46
+<script setup>
47
+import { computed, onMounted, reactive, ref } from 'vue';
48
+const data=reactive({})
49
+const props = defineProps({
50
+  isFinished: String,
51
+  invoiceId:String,
52
+})
53
+const showOrgPicker = ref(false)
54
+const showPersonPicker = ref(false)
55
+//选择企业
56
+const changeOrg = () => {
57
+  if (!isFinished) {
58
+    showOrgPicker.value = true
59
+  }
60
+}
61
+//确认企业
62
+const onOrgConfirm = (value) => {
63
+  if (value) {
64
+    data.invoiceOrgId = value.invoiceOrgId
65
+    data.invoiceOrgName = value.name
66
+    data.personName = ''
67
+    data.invoicePersonId = ''
68
+  }
69
+  showOrgPicker.value = false;
70
+};
71
+//选择报销人
72
+const showOrgPopup = () => {
73
+  if (!isFinished) {
74
+    if (data.invoiceOrgId) {
75
+      showPersonPicker.value = true
76
+    } else {
77
+      Dialog.alert({
78
+        message: '请先选择所属公司'
79
+      }).then(() => { })
80
+    }
81
+  }
82
+}
83
+//确认报销人
84
+const onPersonConfirm = (value) => {
85
+  if (value) {
86
+    let data = {
87
+      invoiceOrgId: data.invoiceOrgId,
88
+      invoiceOrgName: data.invoiceOrgName
89
+    }
90
+    //为了把当前选中报销人员放在请求里
91
+    data.invoicePersonId = value.invoicePersonId
92
+    getDetail()
93
+    //获取详情
94
+    // emit('change', orgSelected.value)
95
+    setTimeout(() => {
96
+      //因为如果客户填错报销人和所属单位 接口返回会默认上次选中的报销人所以需要把当前报销人重新赋值给formData
97
+      data.invoicePersonId = value.invoicePersonId
98
+      data.personName = value.name
99
+      data.invoiceOrgId = data.invoiceOrgId
100
+      data.invoiceOrgName = data.invoiceOrgName
101
+    }, 100)
102
+  }
103
+  //
104
+  showPersonPicker.value = false;
105
+  console.log(data);
106
+};
107
+</script>
108
+<style>
109
+</style>

+ 44
- 44
src/pages/invoice/fill.vue View File

@@ -1,9 +1,5 @@
1 1
 <template>
2
-  <van-form
3
-    @failed="onFailed"
4
-    @submit="onSubmit"
5
-    :readonly="formData.isFinished"
6
-  >
2
+  <van-form @failed="onFailed" @submit="onSubmit" :readonly="isFinished">
7 3
     <h2 :style="{ textAlign: 'center' }">{{ formData.invoiceName }}</h2>
8 4
     <van-cell-group title="报销人信息">
9 5
       <van-field
@@ -21,8 +17,8 @@
21 17
         :style="{ height: '100%', width: '80%' }"
22 18
       >
23 19
         <org-picker
24
-          v-model="formData.orgId"
25
-          :invoiceId="formData.invoiceId"
20
+          v-model="formData.invoiceOrgId"
21
+          :invoiceId="fillData.invoiceId"
26 22
           @change="onOrgConfirm"
27 23
         />
28 24
       </van-popup>
@@ -42,8 +38,8 @@
42 38
       >
43 39
         <person-picker
44 40
           v-model="formData.personId"
45
-          :invoiceId="formData.invoiceId"
46
-          :orgId="formData.orgId"
41
+          :invoiceId="fillData.invoiceId"
42
+          :orgId="formData.invoiceOrgId"
47 43
           @change="onPersonConfirm"
48 44
         />
49 45
       </van-popup>
@@ -101,7 +97,7 @@
101 97
           <van-radio-group
102 98
             v-model="formData.mergeRemark"
103 99
             direction="horizontal"
104
-            :disabled="formData.isFinished"
100
+            :disabled="isFinished"
105 101
           >
106 102
             <van-radio name="是">是</van-radio>
107 103
             <van-radio name="否">否</van-radio>
@@ -127,7 +123,7 @@
127 123
     </van-cell-group>
128 124
     <div style="margin: 16px">
129 125
       <van-button
130
-        v-show="!formData.isFinished"
126
+        v-show="!isFinished"
131 127
         round
132 128
         block
133 129
         type="primary"
@@ -150,30 +146,24 @@ import { useModel } from '@zjxpcyc/vue-tiny-store'
150 146
 const formData = reactive({
151 147
   //班级名称
152 148
   invoiceName: '',
153
-  detailId: undefined,
154 149
   invoiceId: undefined,
155 150
   invoicePersonId: undefined,
156
-  personId: undefined,
157 151
   personName: undefined,
158
-  orgNameId: undefined,
159
-  orgId: undefined,
152
+  invoiceOrgId: undefined,
160 153
   invoiceOrgName: undefined,
161 154
   orgName: undefined,
162 155
   taxNo: undefined,
163 156
   address: undefined,
164 157
   phone: undefined,
165
-  bankId: undefined,
166 158
   bankName: undefined,
167 159
   cardNo: undefined,
168
-  invoiceItemTplId: undefined,
169
-  itemName: undefined,
170
-  charge: undefined,
171
-  //是否结束
172
-  isFinished: false,
173 160
   mergeRemark: '否',
174 161
   status: undefined
175 162
 })
176 163
 const itemList = ref([])
164
+const fillData = ref([])
165
+//是否结束
166
+const isFinished = ref(false)
177 167
 const showOrgPicker = ref(false)
178 168
 const showPersonPicker = ref(false)
179 169
 const router = useRouter();
@@ -188,20 +178,23 @@ onMounted(() => {
188 178
     Dialog.alert({
189 179
       message: '请退出页面重新扫码进入'
190 180
     }).then(() => { })
191
-    formData.isFinished = ture
181
+    isFinished.value = true
192 182
     return
193 183
   }
184
+  if (route.query.isFinished) {
185
+    isFinished.value = true
186
+  }
194 187
   getInvoiceFill(route.query.invoiceId).then(res => {
188
+    fillData.value = res
195 189
     //过期
196 190
     if (dayjs().isAfter(dayjs(res.endDate) || res.status == 2)) {
197
-      formData.isFinished = true
191
+      isFinished.value = true
198 192
       Dialog.alert({
199 193
         message: '该班次已截止如有问题请联系报销助理'
200 194
       })
201
-      formData.invoiceName = res.name
202
-    } else {
203
-      getDetail({ invoiceName: res.name })
204 195
     }
196
+    getDetail()
197
+    formData.invoiceName = res.name
205 198
   }).catch(err => {
206 199
     console.log(err)
207 200
   })
@@ -213,14 +206,14 @@ const onFailed = (errorInfo) => {
213 206
 
214 207
 //选择企业
215 208
 const changeOrg = () => {
216
-  if (!formData.isFinished) {
209
+  if (!isFinished.value) {
217 210
     showOrgPicker.value = true
218 211
   }
219 212
 }
220 213
 //确认企业
221 214
 const onOrgConfirm = (value) => {
222 215
   if (value) {
223
-    formData.orgId = value.invoiceOrgId
216
+    formData.invoiceOrgId = value.invoiceOrgId
224 217
     formData.invoiceOrgName = value.name
225 218
     formData.personName = ''
226 219
     formData.invoicePersonId = ''
@@ -229,8 +222,8 @@ const onOrgConfirm = (value) => {
229 222
 };
230 223
 //选择报销人
231 224
 const showOrgPopup = () => {
232
-  if (!formData.isFinished) {
233
-    if (formData.orgId) {
225
+  if (!isFinished.value) {
226
+    if (formData.invoiceOrgId) {
234 227
       showPersonPicker.value = true
235 228
     } else {
236 229
       Dialog.alert({
@@ -242,28 +235,35 @@ const showOrgPopup = () => {
242 235
 //确认报销人
243 236
 const onPersonConfirm = (value) => {
244 237
   if (value) {
245
-    console.log(value);
246
-    formData.personName = value.name
247
-    formData.invoicePersonId = value.invoicePersonId
248
-    getDetail({
249
-      invoiceName: formData.name,
250
-      invoicePersonId: formData.invoicePersonId,
251
-      personName: formData.personName,
252
-      orgId: formData.orgId,
238
+    let data = {
239
+      invoiceOrgId: formData.invoiceOrgId,
253 240
       invoiceOrgName: formData.invoiceOrgName
254
-    })
241
+    }
242
+    //为了把当前选中报销人员放在请求里
243
+    formData.invoicePersonId = value.invoicePersonId
244
+    getDetail()
245
+    setTimeout(() => {
246
+      //因为如果客户填错报销人和所属单位 接口返回会默认上次选中的报销人所以需要把当前报销人重新赋值给formData
247
+      formData.invoicePersonId = value.invoicePersonId
248
+      formData.personName = value.name
249
+      formData.invoiceOrgId = data.invoiceOrgId
250
+      formData.invoiceOrgName = data.invoiceOrgName
251
+    }, 100)
255 252
   }
256 253
   showPersonPicker.value = false;
254
+  console.log(formData);
257 255
 };
258 256
 //获取模板详情
259
-const getDetail = (data) => {
260
-  getInvoiceModel(route.query.invoiceId, { invoicePersonId: formData.invoicePersonId, personId: personId }).then(res => {
261
-    const info = {
257
+const getDetail = () => {
258
+  getInvoiceModel(route.query.invoiceId, { invoicePersonId: formData.invoicePersonId, personId: personId.value }).then(res => {
259
+    let info = {
262 260
       ...(res.detail || res.tpl),
263
-      ...data
261
+      invoiceName: fillData.value.name,
264 262
     }
263
+    info.mergeRemark = info.mergeRemark || formData.mergeRemark
265 264
     Object.assign(formData, info)
266 265
     itemList.value = info.itemList
266
+    console.log(info);
267 267
   }).catch(err => {
268 268
     console.log(err);
269 269
   })
@@ -276,7 +276,7 @@ const onSubmit = (val) => {
276 276
     }).then(() => { })
277 277
     return;
278 278
   }
279
-  setInvoiceDetail(formData.invoiceId, formData).then(() => {
279
+  setInvoiceDetail(fillData.value.invoiceId, formData).then(() => {
280 280
     Toast.success('提交成功');
281 281
     setTimeout(() => {
282 282
       router.back()

+ 2
- 2
src/pages/publicity/list.vue View File

@@ -12,9 +12,9 @@
12 12
         class="item"
13 13
         v-for="item in list"
14 14
         :key="item.detailId"
15
-        :title="item.orgName"
15
+        :title="item.invoiceOrgName"
16 16
         is-link
17
-        :to="{ name: 'invoice.fill', query: { invoiceId, personId: item.personId } }"
17
+        :to="{ name: 'invoice.fill', query: { invoiceId, personId: item.personId,isFinished:true } }"
18 18
       >
19 19
         <template #value>
20 20
           <span class="pname">{{ item.personName }}</span>