index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. <template>
  2. <flow-form :data="formData" @submit="submitNextActivity">
  3. <card title="基础信息">
  4. <van-form required="auto" ref="form" :readonly="formRead">
  5. <van-cell-group inset>
  6. <van-field
  7. v-model="formData.userNickname"
  8. name="报销人"
  9. label="报销人"
  10. placeholder="报销人"
  11. readonly
  12. :rules="[{ required: true, message: '未获取报销人' }]"
  13. />
  14. <van-field
  15. v-model="formData.deptName"
  16. name="所在部门"
  17. label="所在部门"
  18. placeholder="所在部门"
  19. readonly
  20. :rules="[{ required: true, message: '未获取所在部门' }]"
  21. />
  22. <van-field
  23. v-model="formData.applyTime"
  24. :formatter="formatDate"
  25. name="申请时间"
  26. label="申请时间"
  27. placeholder="申请时间"
  28. readonly
  29. :rules="[{ required: true, message: '请填写申请时间' }]"
  30. />
  31. <van-field
  32. v-model="formData.travelCostNo"
  33. name="报销单号"
  34. label="报销单号"
  35. placeholder="报销单号"
  36. readonly
  37. :rules="[{ required: true, message: '未获取报销单号' }]"
  38. />
  39. <van-field
  40. v-model="formData.startTime"
  41. name="起始时间"
  42. label="起始时间"
  43. placeholder="起始时间"
  44. readonly
  45. :rules="[{ required: true, message: '未获取起始时间' }]"
  46. />
  47. <van-field
  48. v-model="formData.endTime"
  49. name="截止时间"
  50. label="截止时间"
  51. placeholder="截止时间"
  52. readonly
  53. :rules="[{ required: true, message: '未获取截止时间' }]"
  54. />
  55. <van-field
  56. v-model="formData.travelPlace"
  57. name="出差的地点"
  58. label="出差的地点"
  59. placeholder="出差的地点"
  60. :rules="[{ required: true, message: '请填写出差的地点' }]"
  61. />
  62. <van-field
  63. v-model="formData.projectName"
  64. name="项目名称"
  65. label="项目名称"
  66. readonly
  67. placeholder="项目名称"
  68. :rules="[{ required: true, message: '未获取项目' }]"
  69. />
  70. <van-field
  71. v-model="formData.paymentCompanyName"
  72. name="付款单位"
  73. label="付款单位"
  74. placeholder="付款单位"
  75. :rules="[{ required: true, message: '未获取付款单位' }]"
  76. />
  77. <van-field name="是否抵用借款" label="是否抵用借款">
  78. <template #input>
  79. <van-checkbox v-model="formData.dybyCheckBox" shape="square" />
  80. </template>
  81. </van-field>
  82. <van-field
  83. v-model="formData.boatCarAmout"
  84. name="车船费合计(元)"
  85. label="车船费合计(元)"
  86. placeholder="车船费合计(元)"
  87. :rules="[{ required: true, message: '未获取车船费' }]"
  88. />
  89. <van-field
  90. v-model="formData.subsidyAmount"
  91. name="途中补贴合计(元)"
  92. label="途中补贴合计(元)"
  93. placeholder="途中补贴合计(元)"
  94. :rules="[{ required: true, message: '为获取途中补贴' }]"
  95. />
  96. <van-field
  97. v-model="formData.otherAmount"
  98. name="其他费用合计(元)"
  99. label="其他费用合计(元)"
  100. placeholder="其他费用合计(元)"
  101. :rules="[{ required: true, message: '未获取其他费用' }]"
  102. />
  103. <van-field
  104. v-model="formData.carAmount"
  105. name="其中市内车费(元)"
  106. label="其中市内车费(元)"
  107. placeholder="其中市内车费(元)"
  108. :rules="[{ required: true, message: '未获取其中市内车费' }]"
  109. />
  110. <van-field
  111. v-model="formData.totalAmount"
  112. name="报销总金额"
  113. label="报销总金额(元)"
  114. placeholder="报销总金额"
  115. :rules="[{ required: true, message: '未获取报销总金额' }]"
  116. />
  117. <van-field
  118. v-model="formData.totalAmountCn"
  119. name="大写单据总金额"
  120. label="大写单据总金额"
  121. placeholder="大写单据总金额"
  122. :rules="[{ required: true, message: '未获取大写单据总金额' }]"
  123. />
  124. <van-field
  125. v-model="formData.remark"
  126. name="报销备注"
  127. label="报销备注"
  128. placeholder="报销备注"
  129. type="textarea"
  130. rows="3"
  131. autosize
  132. :rules="[{ required: true, message: '未获取报销备注' }]"
  133. />
  134. </van-cell-group>
  135. </van-form>
  136. </card>
  137. <card title="车船费">
  138. <template #right>
  139. <button class="add_btn" @click="popupShow = true" v-if="!formRead">
  140. 新增
  141. </button>
  142. </template>
  143. <template #default>
  144. <div v-for="(item, index) in formData.boatCarList" :key="index">
  145. <van-swipe-cell :disabled="formRead">
  146. <card-cell>
  147. <van-cell
  148. title="出发日期"
  149. :value="formatDate(item.departDate, 'YYYY-MM-DD')"
  150. />
  151. <van-cell title="出发地点" :value="item.departPlace" />
  152. <van-cell
  153. title="到达日期"
  154. :value="formatDate(item.arriveDate, 'YYYY-MM-DD')"
  155. />
  156. <van-cell title="到达地点" :value="item.arrivePlace" />
  157. <van-cell
  158. title="交通工具"
  159. :value="
  160. getDictLabel(
  161. DICT_TYPE.WF_TRAVEL_COST_VEHICLE_TYPE,
  162. item.vehicle
  163. )
  164. "
  165. />
  166. <van-cell title="单据张数" :value="item.invoiceNums" />
  167. <van-cell title="车船费" :value="item.amount" />
  168. <van-cell title="备注" :value="item.remark" />
  169. </card-cell>
  170. </van-swipe-cell>
  171. </div>
  172. </template>
  173. </card>
  174. <card title="其他费用">
  175. <template #right>
  176. <button class="add_btn" @click="popupShow = true" v-if="!formRead">
  177. 新增
  178. </button>
  179. </template>
  180. <template #default>
  181. <div v-for="(item, index) in formData.otherList" :key="index">
  182. <van-swipe-cell :disabled="formRead">
  183. <card-cell>
  184. <van-cell
  185. title="费用类型"
  186. :value="
  187. getDictLabel(
  188. DICT_TYPE.WF_TRAVEL_COST_OTHER_TYPE,
  189. item.costType
  190. )
  191. "
  192. />
  193. <van-cell
  194. title="发生日期"
  195. :value="formatDate(item.costDate, 'YYYY-MM-DD')"
  196. />
  197. <van-cell title="地点" :value="item.costPlace" />
  198. <van-cell title="单据张数" :value="item.invoiceNums" />
  199. <van-cell title="金额" :value="item.amount" />
  200. <van-cell title="备注" :value="item.remark" />
  201. </card-cell>
  202. </van-swipe-cell>
  203. </div>
  204. </template>
  205. </card>
  206. </flow-form>
  207. </template>
  208. <script setup lang="ts">
  209. import { useRoute } from "vue-router";
  210. import { FlowDTO, getNextActivity } from "@/service/flow";
  211. import reqest from "@/utils/request";
  212. import FlowForm from "@/components/flowForm.vue";
  213. import Card from "@/components/card.vue";
  214. import CardCell from "@/components/cardCell.vue";
  215. import { showSuccessToast, showFailToast } from "vant";
  216. import { formatDate } from "@/utils/formatTime";
  217. import { getDictOptions, getDictLabel, DICT_TYPE } from "@/utils/dict";
  218. const popupShow = ref<boolean>(false);
  219. const form = ref(null);
  220. const route = useRoute();
  221. interface FormDataType {
  222. instanceId: string;
  223. id: string;
  224. userNickname: string;
  225. deptName: string;
  226. applyTime: any;
  227. travelCostNo: string;
  228. startTime: any;
  229. endTime: any;
  230. travelPlace: string;
  231. projectName: string;
  232. paymentCompanyName: string;
  233. dybx: any;
  234. dybyCheckBox: boolean;
  235. totalAmount: number | null;
  236. totalAmountCn: string;
  237. boatCarAmout: string;
  238. otherAmount: string;
  239. carAmount: string;
  240. remark: string;
  241. boatCarList: {
  242. travelCostId: string;
  243. departDate: any;
  244. departPlace: string;
  245. arriveDate: any;
  246. arrivePlace: string;
  247. invoiceNums: number;
  248. vehicle: number;
  249. amount: number;
  250. remark: string;
  251. }[];
  252. otherList: {
  253. travelCostId: string;
  254. costDate: any;
  255. costType: string;
  256. costPlace: string;
  257. invoiceNums: number;
  258. vehicle: number;
  259. amount: number;
  260. remark: string;
  261. }[];
  262. }
  263. const formData = ref<FormDataType>({
  264. instanceId: "",
  265. id: "",
  266. userNickname: "",
  267. deptName: "",
  268. applyTime: null,
  269. travelCostNo: "",
  270. startTime: null,
  271. endTime: null,
  272. travelPlace: "",
  273. projectName: "",
  274. paymentCompanyName: "",
  275. dybx: null,
  276. dybyCheckBox: false,
  277. totalAmount: null,
  278. totalAmountCn: "",
  279. boatCarAmout: "",
  280. otherAmount: "",
  281. carAmount: "",
  282. remark: "",
  283. boatCarList: [],
  284. otherList: []
  285. });
  286. const formRead = ref(false);
  287. const { activityInstanceId, participant, flowInstanceId, read, _o } =
  288. route.query as {
  289. activityInstanceId: string;
  290. participant: string;
  291. flowInstanceId: string;
  292. read: string;
  293. _o: string;
  294. };
  295. const activityData: FlowDTO = {
  296. activityInstanceId,
  297. participantId: participant,
  298. flowOpinion: "",
  299. };
  300. const submitNextActivity = async (NextActivity: ()=>Promise<any>) => {
  301. form.value.validate().then(async () => {
  302. //工作流转件
  303. NextActivity();
  304. });
  305. };
  306. const jsonToFormData = (json: any): FormData | null => {
  307. const keys: string[] = Object.keys(json);
  308. if (keys.length > 0) {
  309. const formData = new FormData();
  310. keys.forEach((key) => {
  311. formData.append(
  312. key,
  313. json[key] instanceof Object ? JSON.stringify(json[key]) : json[key]
  314. );
  315. });
  316. return formData;
  317. }
  318. return null;
  319. };
  320. /** 初始化表单数据 */
  321. const initFormData = async () => {
  322. const result = await reqest.get(
  323. `/business/TravelCost/mobileAdd?flowInstanceId=${flowInstanceId}`
  324. );
  325. formData.value = result.data;
  326. formData.value.applyTime = formatDate(formData.value.applyTime);
  327. formData.value.startTime = formatDate(formData.value.startTime, "YYYY-MM-DD");
  328. formData.value.endTime = formatDate(formData.value.endTime, "YYYY-MM-DD");
  329. if (formData.value.dybx === 1) {
  330. formData.value.dybyCheckBox = true;
  331. } else {
  332. formData.value.dybyCheckBox = false;
  333. }
  334. totalBoatCarAmount()
  335. totalOtherAmount()
  336. };
  337. /** 车船费合计计算 */
  338. const totalBoatCarAmount = () => {
  339. let amonut = 0;
  340. formData.value.boatCarList.forEach((obj: { amount: any }) => {
  341. amonut += Number(obj.amount);
  342. });
  343. formData.value.boatCarAmout = amonut.toFixed(2);
  344. };
  345. /** 其他费用合计计算 */
  346. const totalOtherAmount = () => {
  347. let amonut = 0;
  348. let carAmount = 0;
  349. formData.value.otherList.forEach(
  350. (obj: { costType: string; amount: any }) => {
  351. amonut += Number(obj.amount);
  352. if (obj.costType == "1") {
  353. carAmount += Number(obj.amount);
  354. }
  355. }
  356. );
  357. formData.value.otherAmount = amonut.toFixed(2);
  358. formData.value.carAmount = carAmount.toFixed(2);
  359. };
  360. /** 初始化 */
  361. onMounted(() => {
  362. initFormData();
  363. if (read === "1" || _o === "v") {
  364. formRead.value = true;
  365. }
  366. });
  367. </script>
  368. <style lang="scss" scoped>
  369. @import "./index.scss";
  370. </style>