李志伟 пре 2 година
родитељ
комит
fa1f54088d

+ 0
- 7
src/pages/invoice/components/DetailInfo.vue Прегледај датотеку

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

+ 74
- 0
src/pages/invoice/components/InvoiceInfo.vue Прегледај датотеку

@@ -0,0 +1,74 @@
1
+<template>
2
+  <van-cell-group title="开票单位">
3
+    <van-field
4
+      label="开票单位"
5
+      v-model="props.pdata.orgName"
6
+      name="orgName"
7
+      placeholder="请输入开票单位"
8
+      :rules="[{ required: true, message: '请输入开票单位' }]"
9
+    />
10
+    <van-field
11
+      label="纳 税 号"
12
+      v-model="props.pdata.taxNo"
13
+      name="taxNo"
14
+      placeholder="请输入纳税识别号"
15
+      :rules="[{ required: true, message: '请输入纳税识别号' }]"
16
+    />
17
+    <van-field
18
+      label="单位地址"
19
+      v-model="props.pdata.address"
20
+      name="address"
21
+      placeholder="请输入单位地址"
22
+      :rules="[{ required: true, message: '请输入单位地址' }]"
23
+    />
24
+    <van-field
25
+      label="单位电话"
26
+      v-model="props.pdata.phone"
27
+      name="phone"
28
+      placeholder="请输入单位电话"
29
+      :rules="[{ required: true, message: '请输入单位电话' }]"
30
+    />
31
+    <van-field
32
+      label="开户银行"
33
+      v-model="props.pdata.bankName"
34
+      name="bankName"
35
+      placeholder="请输入开户银行"
36
+      :rules="[{ required: true, message: '请输入开户银行' }]"
37
+    />
38
+    <van-field
39
+      label="开户账户"
40
+      v-model="props.pdata.cardNo"
41
+      name="cardNo"
42
+      placeholder="请输入开户行账号"
43
+      :rules="[{ required: true, message: '请输入开户行账号' }]"
44
+    />
45
+    <van-field
46
+      name="mergeRemark"
47
+      label="是否合开"
48
+      error-message="如果合开请和报销专员联系"
49
+    >
50
+      <template #input>
51
+        <van-radio-group
52
+          v-model="props.pdata.mergeRemark"
53
+          direction="horizontal"
54
+          :disabled="props.isFinished"
55
+        >
56
+          <van-radio name="是">是</van-radio>
57
+          <van-radio name="否">否</van-radio>
58
+        </van-radio-group>
59
+      </template>
60
+    </van-field>
61
+  </van-cell-group>
62
+</template>
63
+<script setup>
64
+import { ref, reactive, watch } from 'vue';
65
+const props = defineProps({
66
+  isFinished: String,
67
+  pdata: {
68
+    type: Object,
69
+    default: () => ({})
70
+  }
71
+})
72
+</script>
73
+<style>
74
+</style>

+ 38
- 0
src/pages/invoice/components/ItemTpl.vue Прегледај датотеку

@@ -0,0 +1,38 @@
1
+<template>
2
+<van-cell-group v-if="props.itemList.length != 0" title="报销信息">
3
+      <div class="itembox" v-for="item in props.itemList" :key="item.invoiceItemId">
4
+        <van-cell title="报销项目">
5
+          <template #value>
6
+            <span style="color: #000">{{ item.name }}</span>
7
+          </template>
8
+        </van-cell>
9
+        <van-cell title="开票金额">
10
+          <template #value>
11
+            <span style="color: #000">{{ item.charge }}</span>
12
+          </template>
13
+        </van-cell>
14
+        <div class="lastLine" />
15
+      </div>
16
+    </van-cell-group>
17
+</template>
18
+<script setup>
19
+const props = defineProps({
20
+  itemList: {
21
+    type: Array,
22
+    default: () => ({})
23
+  }
24
+})
25
+</script>
26
+<style lang="less" scoped>
27
+.lastLine::after {
28
+  position: absolute;
29
+  box-sizing: border-box;
30
+  content: " ";
31
+  pointer-events: none;
32
+  right: var(--van-padding-md);
33
+  bottom: 0;
34
+  left: var(--van-padding-md);
35
+  border-bottom: 1px solid var(--van-cell-border-color);
36
+  transform: scaleY(0.5);
37
+}
38
+</style>

+ 38
- 39
src/pages/invoice/components/PersonInfo.vue Прегледај датотеку

@@ -2,7 +2,7 @@
2 2
   <van-cell-group title="报销人信息">
3 3
     <van-field
4 4
       label="所属公司"
5
-      v-model="data.invoiceOrgName"
5
+      v-model="value.invoiceOrgName"
6 6
       name="invoiceOrgName"
7 7
       readonly
8 8
       @click="changeOrg"
@@ -15,14 +15,14 @@
15 15
       :style="{ height: '100%', width: '80%' }"
16 16
     >
17 17
       <org-picker
18
-        v-model="data.invoiceOrgId"
19
-        :invoiceId="invoiceId"
18
+        v-model="value.invoiceOrgId"
19
+        :invoiceId="props.invoiceId"
20 20
         @change="onOrgConfirm"
21 21
       />
22 22
     </van-popup>
23 23
     <van-field
24 24
       label="报销人"
25
-      v-model="data.personName"
25
+      v-model="value.personName"
26 26
       name="personName"
27 27
       readonly
28 28
       @click="showOrgPopup"
@@ -35,43 +35,57 @@
35 35
       :style="{ height: '100%', width: '80%' }"
36 36
     >
37 37
       <person-picker
38
-        v-model="data.personId"
39
-        :invoiceId="invoiceId"
40
-        :orgId="formData.invoiceOrgId"
38
+        v-model="value.personId"
39
+        :invoiceId="props.invoiceId"
40
+        :orgId="value.invoiceOrgId"
41 41
         @change="onPersonConfirm"
42 42
       />
43 43
     </van-popup>
44 44
   </van-cell-group>
45 45
 </template>
46 46
 <script setup>
47
-import { computed, onMounted, reactive, ref } from 'vue';
48
-const data=reactive({})
47
+import { ref, reactive, watch } from 'vue';
48
+import { Dialog } from 'vant'
49
+
50
+const value = reactive({});
49 51
 const props = defineProps({
50 52
   isFinished: String,
51
-  invoiceId:String,
53
+  invoiceId: String,
54
+  pdata: {
55
+    type: Object,
56
+    default: () => ({})
57
+  }
52 58
 })
59
+const emit = defineEmits(['changeOrgValue','changePersonValue'])
60
+watch(() => props.pdata, (val) => {
61
+  Object.assign(value, val)
62
+},
63
+  { immediate: true, deep: true }
64
+)
53 65
 const showOrgPicker = ref(false)
54 66
 const showPersonPicker = ref(false)
67
+
55 68
 //选择企业
56 69
 const changeOrg = () => {
57
-  if (!isFinished) {
70
+  if (!props.isFinished) {
58 71
     showOrgPicker.value = true
59 72
   }
60 73
 }
61 74
 //确认企业
62
-const onOrgConfirm = (value) => {
63
-  if (value) {
64
-    data.invoiceOrgId = value.invoiceOrgId
65
-    data.invoiceOrgName = value.name
66
-    data.personName = ''
67
-    data.invoicePersonId = ''
75
+const onOrgConfirm = (val) => {
76
+  if (val) {
77
+    value.invoiceOrgId = val.invoiceOrgId
78
+    value.invoiceOrgName = val.name
79
+    value.personName = undefined
80
+    value.invoicePersonId = undefined
81
+    emit('changeOrgValue', value)
68 82
   }
69 83
   showOrgPicker.value = false;
70 84
 };
71 85
 //选择报销人
72 86
 const showOrgPopup = () => {
73
-  if (!isFinished) {
74
-    if (data.invoiceOrgId) {
87
+  if (!props.isFinished) {
88
+    if (value.invoiceOrgId) {
75 89
       showPersonPicker.value = true
76 90
     } else {
77 91
       Dialog.alert({
@@ -81,28 +95,13 @@ const showOrgPopup = () => {
81 95
   }
82 96
 }
83 97
 //确认报销人
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)
98
+const onPersonConfirm = (val) => {
99
+  if (val) {
100
+    value.invoicePersonId = val.invoicePersonId
101
+    value.personName = val.name
102
+    emit('changePersonValue', value)
102 103
   }
103
-  //
104 104
   showPersonPicker.value = false;
105
-  console.log(data);
106 105
 };
107 106
 </script>
108 107
 <style>

+ 37
- 215
src/pages/invoice/fill.vue Прегледај датотеку

@@ -1,126 +1,17 @@
1 1
 <template>
2 2
   <van-form @failed="onFailed" @submit="onSubmit" :readonly="isFinished">
3
-    <h2 :style="{ textAlign: 'center' }">{{ formData.invoiceName }}</h2>
4
-    <van-cell-group title="报销人信息">
5
-      <van-field
6
-        label="所属公司"
7
-        v-model="formData.invoiceOrgName"
8
-        name="invoiceOrgName"
9
-        readonly
10
-        @click="changeOrg"
11
-        placeholder="请输入所属公司"
12
-        :rules="[{ required: true, message: '请输入所属公司' }]"
13
-      />
14
-      <van-popup
15
-        v-model:show="showOrgPicker"
16
-        position="left"
17
-        :style="{ height: '100%', width: '80%' }"
18
-      >
19
-        <org-picker
20
-          v-model="formData.invoiceOrgId"
21
-          :invoiceId="fillData.invoiceId"
22
-          @change="onOrgConfirm"
23
-        />
24
-      </van-popup>
25
-      <van-field
26
-        label="报销人"
27
-        v-model="formData.personName"
28
-        name="personName"
29
-        readonly
30
-        @click="showOrgPopup"
31
-        placeholder="请输入报销人"
32
-        :rules="[{ required: true, message: '请输入报销人' }]"
33
-      />
34
-      <van-popup
35
-        v-model:show="showPersonPicker"
36
-        position="left"
37
-        :style="{ height: '100%', width: '80%' }"
38
-      >
39
-        <person-picker
40
-          v-model="formData.personId"
41
-          :invoiceId="fillData.invoiceId"
42
-          :orgId="formData.invoiceOrgId"
43
-          @change="onPersonConfirm"
44
-        />
45
-      </van-popup>
46
-    </van-cell-group>
3
+    <h2 :style="{ textAlign: 'center' }">{{ fillData.name }}</h2>
4
+    <person-info
5
+      :isFinished="isFinished"
6
+      :invoiceId="route.query.invoiceId"
7
+      :pdata="personData"
8
+      @changeOrgValue="changeOrg"
9
+      @changePersonValue="changePerson"
10
+    />
11
+    <invoice-info :isFinished="isFinished" :pdata="formData" />
47 12
 
48
-    <van-cell-group title="开票单位">
49
-      <van-field
50
-        label="开票单位"
51
-        v-model="formData.orgName"
52
-        name="orgName"
53
-        placeholder="请输入开票单位"
54
-        :rules="[{ required: true, message: '请输入开票单位' }]"
55
-      />
56
-      <van-field
57
-        label="纳 税 号"
58
-        v-model="formData.taxNo"
59
-        name="taxNo"
60
-        placeholder="请输入纳税识别号"
61
-        :rules="[{ required: true, message: '请输入纳税识别号' }]"
62
-      />
63
-      <van-field
64
-        label="单位地址"
65
-        v-model="formData.address"
66
-        name="address"
67
-        placeholder="请输入单位地址"
68
-        :rules="[{ required: true, message: '请输入单位地址' }]"
69
-      />
70
-      <van-field
71
-        label="单位电话"
72
-        v-model="formData.phone"
73
-        name="phone"
74
-        placeholder="请输入单位电话"
75
-        :rules="[{ required: true, message: '请输入单位电话' }]"
76
-      />
77
-      <van-field
78
-        label="开户银行"
79
-        v-model="formData.bankName"
80
-        name="bankName"
81
-        placeholder="请输入开户银行"
82
-        :rules="[{ required: true, message: '请输入开户银行' }]"
83
-      />
84
-      <van-field
85
-        label="开户账户"
86
-        v-model="formData.cardNo"
87
-        name="cardNo"
88
-        placeholder="请输入开户行账号"
89
-        :rules="[{ required: true, message: '请输入开户行账号' }]"
90
-      />
91
-      <van-field
92
-        name="radio"
93
-        label="是否合开"
94
-        error-message="如果合开请和报销专员联系"
95
-      >
96
-        <template #input>
97
-          <van-radio-group
98
-            v-model="formData.mergeRemark"
99
-            direction="horizontal"
100
-            :disabled="isFinished"
101
-          >
102
-            <van-radio name="是">是</van-radio>
103
-            <van-radio name="否">否</van-radio>
104
-          </van-radio-group>
105
-        </template>
106
-      </van-field>
107
-    </van-cell-group>
13
+    <item-tpl :itemList="itemList" />
108 14
 
109
-    <van-cell-group v-if="itemList.length != 0" title="报销信息">
110
-      <div class="itembox" v-for="item in itemList" :key="item.invoiceItemId">
111
-        <van-cell title="报销项目">
112
-          <template #value>
113
-            <span style="color: #000">{{ item.name }}</span>
114
-          </template>
115
-        </van-cell>
116
-        <van-cell title="开票金额">
117
-          <template #value>
118
-            <span style="color: #000">{{ item.charge }}</span>
119
-          </template>
120
-        </van-cell>
121
-        <div class="lastLine" />
122
-      </div>
123
-    </van-cell-group>
124 15
     <div style="margin: 16px">
125 16
       <van-button
126 17
         v-show="!isFinished"
@@ -142,36 +33,32 @@ import { Dialog, Toast } from 'vant'
142 33
 import dayjs from 'dayjs'
143 34
 import { getInvoiceModel, setInvoiceDetail, getInvoiceFill } from '@/services/invoice'
144 35
 import { useModel } from '@zjxpcyc/vue-tiny-store'
36
+import PersonInfo from './components/PersonInfo.vue'
37
+import InvoiceInfo from './components/InvoiceInfo.vue'
38
+import ItemTpl from './components/ItemTpl.vue'
145 39
 
146
-const formData = reactive({
147
-  //班级名称
148
-  invoiceName: '',
149
-  invoiceId: undefined,
150
-  invoicePersonId: undefined,
151
-  personName: undefined,
152
-  invoiceOrgId: undefined,
153
-  invoiceOrgName: undefined,
154
-  orgName: undefined,
155
-  taxNo: undefined,
156
-  address: undefined,
157
-  phone: undefined,
158
-  bankName: undefined,
159
-  cardNo: undefined,
160
-  mergeRemark: '否',
161
-  status: undefined
162
-})
40
+const formData = reactive({})
41
+//person组件数据
42
+const personData = ref({})
163 43
 const itemList = ref([])
164 44
 const fillData = ref([])
165 45
 //是否结束
166 46
 const isFinished = ref(false)
167
-const showOrgPicker = ref(false)
168
-const showPersonPicker = ref(false)
169 47
 const router = useRouter();
170 48
 const route = useRoute();
171 49
 const { user } = useModel('user')
172 50
 
173 51
 const personId = computed(() => route.query.personId || user.personId)
174 52
 
53
+const changeOrg = (val) => {
54
+  personData.value = val
55
+}
56
+const changePerson = (val) => {
57
+  personData.value = val
58
+  formData.invoicePersonId = val.invoicePersonId
59
+  getDetail()
60
+}
61
+
175 62
 onMounted(() => {
176 63
   //不是扫码进入
177 64
   if (!route.query.invoiceId) {
@@ -194,7 +81,6 @@ onMounted(() => {
194 81
       })
195 82
     }
196 83
     getDetail()
197
-    formData.invoiceName = res.name
198 84
   }).catch(err => {
199 85
     console.log(err)
200 86
   })
@@ -204,66 +90,20 @@ const onFailed = (errorInfo) => {
204 90
   console.log('failed', formData);
205 91
 };
206 92
 
207
-//选择企业
208
-const changeOrg = () => {
209
-  if (!isFinished.value) {
210
-    showOrgPicker.value = true
211
-  }
212
-}
213
-//确认企业
214
-const onOrgConfirm = (value) => {
215
-  if (value) {
216
-    formData.invoiceOrgId = value.invoiceOrgId
217
-    formData.invoiceOrgName = value.name
218
-    formData.personName = ''
219
-    formData.invoicePersonId = ''
220
-  }
221
-  showOrgPicker.value = false;
222
-};
223
-//选择报销人
224
-const showOrgPopup = () => {
225
-  if (!isFinished.value) {
226
-    if (formData.invoiceOrgId) {
227
-      showPersonPicker.value = true
228
-    } else {
229
-      Dialog.alert({
230
-        message: '请先选择所属公司'
231
-      }).then(() => { })
232
-    }
233
-  }
234
-}
235
-//确认报销人
236
-const onPersonConfirm = (value) => {
237
-  if (value) {
238
-    let data = {
239
-      invoiceOrgId: formData.invoiceOrgId,
240
-      invoiceOrgName: formData.invoiceOrgName
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)
252
-  }
253
-  showPersonPicker.value = false;
254
-  console.log(formData);
255
-};
93
+
256 94
 //获取模板详情
257 95
 const getDetail = () => {
258 96
   getInvoiceModel(route.query.invoiceId, { invoicePersonId: formData.invoicePersonId, personId: personId.value }).then(res => {
259
-    let info = {
260
-      ...(res.detail || res.tpl),
261
-      invoiceName: fillData.value.name,
262
-    }
97
+    let info = res.detail || res.tpl
263 98
     info.mergeRemark = info.mergeRemark || formData.mergeRemark
264 99
     Object.assign(formData, info)
100
+    if (!personData.value.invoicePersonId) {
101
+      personData.value.invoiceOrgId = info.invoiceOrgId
102
+      personData.value.invoiceOrgName = info.invoiceOrgName
103
+      personData.value.personName = info.personName
104
+      personData.value.invoicePersonId = info.invoicePersonId
105
+    }
265 106
     itemList.value = info.itemList
266
-    console.log(info);
267 107
   }).catch(err => {
268 108
     console.log(err);
269 109
   })
@@ -276,7 +116,9 @@ const onSubmit = (val) => {
276 116
     }).then(() => { })
277 117
     return;
278 118
   }
279
-  setInvoiceDetail(fillData.value.invoiceId, formData).then(() => {
119
+  //需要调用中间列表的提交事件获取数据
120
+  let value = { ...formData, ...val, ...personData.value }
121
+  setInvoiceDetail(fillData.value.invoiceId, value).then(() => {
280 122
     Toast.success('提交成功');
281 123
     setTimeout(() => {
282 124
       router.back()
@@ -285,24 +127,4 @@ const onSubmit = (val) => {
285 127
     console.log(err);
286 128
   })
287 129
 }
288
-
289
-</script>
290
-<style lang="less" scoped>
291
-.lastLine::after {
292
-  position: absolute;
293
-  box-sizing: border-box;
294
-  content: " ";
295
-  pointer-events: none;
296
-  right: var(--van-padding-md);
297
-  bottom: 0;
298
-  left: var(--van-padding-md);
299
-  border-bottom: 1px solid var(--van-cell-border-color);
300
-  transform: scaleY(0.5);
301
-}
302
-.cellClassName {
303
-  .van-cell__value {
304
-    min-width: 80% !important; //可根据自己需求设定值
305
-    text-align: left !important;
306
-  }
307
-}
308
-</style>
130
+</script>