index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. <template>
  2. <div class="pageIndexClass">
  3. <div class="content">
  4. <byTable :source="sourceList.data" :pagination="sourceList.pagination" :selectConfig="selectConfig" :config="config" :loading="loading"
  5. highlight-current-row :action-list="[
  6. {
  7. text: '添加',
  8. action: () => openModal('add'),
  9. },
  10. ]" @get-list="getList">
  11. <template #code="{item}">
  12. <div style="width:100%">
  13. <span class="el-click" @click="getDtl(item)">{{item.code}}</span>
  14. </div>
  15. </template>
  16. </byTable>
  17. </div>
  18. <el-dialog :title="modalType == 'add' ? '归还' : '编辑'" v-if="dialogVisible" v-model="dialogVisible" width="500">
  19. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit" v-loading="loadingDialog">
  20. </byForm>
  21. <template #footer>
  22. <el-button @click="dialogVisible = false" size="default">取 消</el-button>
  23. <el-button type="primary" @click="submitForm()" size="default">确 定</el-button>
  24. </template>
  25. </el-dialog>
  26. </div>
  27. </template>
  28. <script setup>
  29. import { computed, ref } from "vue";
  30. import byTable from "@/components/byTable/index";
  31. import byForm from "@/components/byForm/index";
  32. import useUserStore from "@/store/modules/user";
  33. import moment from "moment";
  34. // import $bus from "@/bus/index.js";
  35. import useRefreshTableData from "@/hooks/refreshTableData";
  36. const { proxy } = getCurrentInstance();
  37. const sealType = computed(() => proxy.useUserStore().allDict["seal_type"]);
  38. const sealCategory = computed(
  39. () => proxy.useUserStore().allDict["seal_category"]
  40. );
  41. const sealIsContract = computed(
  42. () => proxy.useUserStore().allDict["seal_is_contract"]
  43. );
  44. const userList = ref([]);
  45. const deptData = ref([]);
  46. const typeData = ref([
  47. {
  48. label: "收入",
  49. value: "10",
  50. },
  51. {
  52. label: "支出",
  53. value: "20",
  54. },
  55. ]);
  56. const sourceList = ref({
  57. data: [],
  58. pagination: {
  59. total: 0,
  60. pageNum: 1,
  61. pageSize: 10,
  62. keyword: "",
  63. },
  64. });
  65. const loading = ref(false);
  66. const statusData = ref([
  67. {
  68. label: "草稿",
  69. value: 0,
  70. },
  71. {
  72. label: "审批中",
  73. value: 10,
  74. },
  75. {
  76. label: "审批驳回",
  77. value: 20,
  78. },
  79. {
  80. label: "审批通过",
  81. value: 30,
  82. },
  83. {
  84. label: "作废",
  85. value: 88,
  86. },
  87. ]);
  88. const isReturnedData = ref([
  89. {
  90. label: "是",
  91. value: 1,
  92. },
  93. {
  94. label: "否",
  95. value: 0,
  96. },
  97. ]);
  98. const useMethodData = ref([
  99. {
  100. dictValue: "借章",
  101. dictKey: "1",
  102. },
  103. {
  104. dictValue: "盖章",
  105. dictKey: "2",
  106. },
  107. ]);
  108. const selectConfig = computed(() => {
  109. return [
  110. {
  111. label: "审批状态",
  112. prop: "status",
  113. data: statusData.value,
  114. },
  115. // {
  116. // label: "是否归还",
  117. // prop: "isReturned",
  118. // data: isReturnedData.value,
  119. // },
  120. // {
  121. // label: "使用方式",
  122. // prop: "useMethod",
  123. // data: useMethodData.value,
  124. // },
  125. // {
  126. // label: "印章类型",
  127. // prop: "sealType",
  128. // data: sealType.value,
  129. // },
  130. // {
  131. // label: "盖章类别",
  132. // prop: "stampedType",
  133. // data: sealCategory.value,
  134. // },
  135. ];
  136. });
  137. const config = computed(() => {
  138. return [
  139. {
  140. attrs: {
  141. label: "流水号",
  142. slot: "code",
  143. width: 130,
  144. fixed: "left",
  145. },
  146. },
  147. {
  148. attrs: {
  149. label: "提交人",
  150. prop: "createUserName",
  151. width: 130,
  152. },
  153. },
  154. {
  155. attrs: {
  156. label: "提交日期",
  157. prop: "applyTime",
  158. width: 100,
  159. },
  160. },
  161. {
  162. attrs: {
  163. label: "发票金额",
  164. prop: "amount",
  165. width: 130,
  166. },
  167. render(val) {
  168. return proxy.moneyFormat(val, 2);
  169. },
  170. },
  171. {
  172. attrs: {
  173. label: "摘要",
  174. prop: "remark",
  175. },
  176. },
  177. {
  178. attrs: {
  179. label: "审批状态",
  180. prop: "status",
  181. width: 100,
  182. fixed: "right",
  183. },
  184. render(type) {
  185. return proxy.dictValueLabel(type, statusData.value);
  186. },
  187. },
  188. {
  189. attrs: {
  190. label: "操作",
  191. width: "120",
  192. align: "center",
  193. fixed: "right",
  194. },
  195. renderHTML(row) {
  196. return row.createUser == proxy.useUserStore().user.userId
  197. ? [
  198. row.status == 0
  199. ? {
  200. attrs: {
  201. label: "修改",
  202. type: "primary",
  203. text: true,
  204. },
  205. el: "button",
  206. click() {
  207. clickUpdate(row);
  208. },
  209. }
  210. : {},
  211. row.status == 0
  212. ? {
  213. attrs: {
  214. label: "删除",
  215. type: "danger",
  216. text: true,
  217. },
  218. el: "button",
  219. click() {
  220. proxy
  221. .msgConfirm()
  222. .then((res) => {
  223. proxy
  224. .post("/personalInvoice/delete", {
  225. id: row.id,
  226. })
  227. .then((res) => {
  228. proxy.msgTip("操作成功", 1);
  229. getList();
  230. });
  231. })
  232. .catch((err) => {});
  233. },
  234. }
  235. : {},
  236. row.status == 10 || row.status == 30
  237. ? {
  238. attrs: {
  239. label: "作废",
  240. type: "danger",
  241. text: true,
  242. },
  243. el: "button",
  244. click() {
  245. proxy
  246. .msgConfirm()
  247. .then((res) => {
  248. proxy
  249. .post("/personalInvoice/cancellation", {
  250. id: row.id,
  251. })
  252. .then((res) => {
  253. proxy.msgTip("操作成功", 1);
  254. getList();
  255. });
  256. })
  257. .catch((err) => {});
  258. },
  259. }
  260. : {},
  261. ]
  262. : [];
  263. },
  264. },
  265. ];
  266. });
  267. const corporationList = ref([]);
  268. const getList = async (req) => {
  269. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  270. loading.value = true;
  271. proxy
  272. .post("/personalInvoice/page", sourceList.value.pagination)
  273. .then((res) => {
  274. sourceList.value.data = res.rows;
  275. sourceList.value.pagination.total = res.total;
  276. setTimeout(() => {
  277. loading.value = false;
  278. }, 200);
  279. });
  280. };
  281. getList();
  282. const getDeptData = (val) => {
  283. proxy
  284. .get("/tenantUser/list", {
  285. pageNum: 1,
  286. pageSize: 10000,
  287. tenantId: proxy.useUserStore().user.tenantId,
  288. companyId: proxy.useUserStore().user.companyId,
  289. })
  290. .then((res) => {
  291. userList.value = res.rows.map((item) => {
  292. return {
  293. ...item,
  294. label: item.nickName,
  295. value: item.userId,
  296. };
  297. });
  298. });
  299. proxy
  300. .get("/tenantDept/list", {
  301. pageNum: 1,
  302. pageSize: 9999,
  303. keyword: "",
  304. ancestors: proxy.useUserStore().user.companyId,
  305. tenantId: proxy.useUserStore().user.tenantId,
  306. // type: 2,
  307. })
  308. .then((res) => {
  309. deptData.value = proxy.handleTree(res.data, "deptId");
  310. });
  311. };
  312. getDeptData();
  313. const modalType = ref("add");
  314. const dialogVisible = ref(false);
  315. const loadingDialog = ref(false);
  316. const submit = ref(null);
  317. const formOption = reactive({
  318. inline: true,
  319. labelWidth: 100,
  320. itemWidth: 100,
  321. rules: [],
  322. });
  323. const formConfig = computed(() => {
  324. return [
  325. {
  326. type: "date",
  327. prop: "realityReturnedTime",
  328. itemType: "date",
  329. label: "归还日期",
  330. itemWidth: 100,
  331. disabled: false,
  332. },
  333. ];
  334. });
  335. const rules = ref({
  336. realityReturnedTime: [
  337. { required: true, message: "请选择归还日期", trigger: "change" },
  338. ],
  339. });
  340. const formData = reactive({
  341. data: {
  342. accountRemainderList: [{ currency: "", remainder: undefined }],
  343. },
  344. });
  345. const openModal = (val) => {
  346. // modalType.value = val;
  347. // formData.data = {
  348. // accountRemainderList: [{ currency: "", remainder: undefined }],
  349. // };
  350. // loadingDialog.value = false;
  351. // dialogVisible.value = true;
  352. proxy.$router.replace({
  353. path: "/platform_manage/process/processApproval",
  354. query: {
  355. flowKey: "personal_invoice_flow",
  356. flowName: "个人电子发票提交发起流程",
  357. random: proxy.random(),
  358. },
  359. });
  360. };
  361. const clickBalance = () => {
  362. if (
  363. formData.data.accountRemainderList &&
  364. formData.data.accountRemainderList.length > 0
  365. ) {
  366. formData.data.accountRemainderList.push({
  367. currency: "",
  368. remainder: undefined,
  369. });
  370. } else {
  371. formData.data.accountRemainderList = [
  372. { currency: "", remainder: undefined },
  373. ];
  374. }
  375. };
  376. const handleRemove = (index) => {
  377. formData.data.accountRemainderList.splice(index, 1);
  378. };
  379. const isRepeat = (arr) => {
  380. var hash = {};
  381. for (var i in arr) {
  382. if (hash[arr[i].currency]) return true;
  383. hash[arr[i].currency] = true;
  384. }
  385. return false;
  386. };
  387. const submitForm = () => {
  388. submit.value.handleSubmit(() => {
  389. loadingDialog.value = true;
  390. proxy.post("/personalInvoice/returned", formData.data).then(
  391. () => {
  392. proxy.msgTip("操作成功", 1);
  393. dialogVisible.value = false;
  394. loadingDialog.value = false;
  395. getList();
  396. },
  397. (err) => {
  398. console.log(err);
  399. loadingDialog.value = false;
  400. }
  401. );
  402. // if (
  403. // formData.data.accountRemainderList &&
  404. // formData.data.accountRemainderList.length > 0
  405. // ) {
  406. // if (isRepeat(formData.data.accountRemainderList)) {
  407. // return ElMessage("请勿重复添加货币余额");
  408. // } else {
  409. // loadingDialog.value = true;
  410. // proxy.post("/accountManagement/" + modalType.value, formData.data).then(
  411. // () => {
  412. // ElMessage({
  413. // message: modalType.value == "add" ? "添加成功" : "编辑成功",
  414. // type: "success",
  415. // });
  416. // dialogVisible.value = false;
  417. // getList();
  418. // },
  419. // (err) => {
  420. // console.log(err);
  421. // loadingDialog.value = false;
  422. // }
  423. // );
  424. // }
  425. // } else {
  426. // return ElMessage("请添加至少一条类型余额");
  427. // }
  428. });
  429. };
  430. const update = (row) => {
  431. loadingDialog.value = false;
  432. modalType.value = "edit";
  433. formData.data = proxy.deepClone(row);
  434. dialogVisible.value = true;
  435. };
  436. const clickUpdate = (row) => {
  437. proxy.$router.push({
  438. path: "/platform_manage/process/processApproval",
  439. query: {
  440. flowKey: "personal_invoice_flow",
  441. flowName: "个人电子发票提交发起流程",
  442. random: proxy.random(),
  443. businessId: row.id,
  444. },
  445. });
  446. };
  447. const getDtl = (row) => {
  448. proxy.$router.push({
  449. path: "/platform_manage/process/processApproval",
  450. query: {
  451. flowKey: "personal_invoice_flow",
  452. flowName: "个人电子发票提交流程查看",
  453. random: proxy.random(),
  454. businessId: row.id,
  455. processType: 20,
  456. },
  457. });
  458. };
  459. const handleReturn = (row) => {
  460. modalType.value = "add";
  461. formData.data = {
  462. id: row.id,
  463. realityReturnedTime: moment().format("YYYY-HH-MM"),
  464. };
  465. dialogVisible.value = true;
  466. };
  467. useRefreshTableData(getList);
  468. </script>
  469. <style lang="scss" scoped>
  470. .tenant {
  471. padding: 20px;
  472. }
  473. ::v-deep(.el-input-number .el-input__inner) {
  474. text-align: left;
  475. }
  476. </style>