index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. <template>
  2. <div class="user">
  3. <div class="content">
  4. <byTable
  5. :source="sourceList.data"
  6. :pagination="sourceList.pagination"
  7. :config="config"
  8. :loading="loading"
  9. highlight-current-row
  10. :selectConfig="selectConfig"
  11. :table-events="{
  12. //element talbe事件都能传
  13. select: select,
  14. }"
  15. :action-list="[]"
  16. @get-list="getList"
  17. >
  18. <template #pic="{ item }">
  19. <div v-if="item.fileList.length > 0">
  20. <img
  21. :src="item.fileList[0].fileUrl"
  22. class="pic"
  23. @click="handleClickFile(item.fileList[0])"
  24. />
  25. </div>
  26. <div v-else></div>
  27. </template>
  28. </byTable>
  29. </div>
  30. <el-dialog
  31. :title="modalType == 'add' ? '打款' : '打款'"
  32. v-model="dialogVisible"
  33. width="500"
  34. v-loading="loading"
  35. >
  36. <byForm
  37. :formConfig="formConfig"
  38. :formOption="formOption"
  39. v-model="formData.data"
  40. :rules="rules"
  41. ref="byform"
  42. >
  43. <template #productPic>
  44. <div>
  45. <el-upload
  46. v-model:fileList="fileList"
  47. action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
  48. :data="uploadData"
  49. list-type="picture-card"
  50. :on-remove="handleRemove"
  51. :on-success="handleSuccess"
  52. :before-upload="handleBeforeUpload"
  53. >
  54. <el-icon><Plus /></el-icon>
  55. </el-upload>
  56. </div>
  57. </template>
  58. </byForm>
  59. <template #footer>
  60. <el-button @click="dialogVisible = false" size="large">取 消</el-button>
  61. <el-button
  62. type="primary"
  63. @click="submitForm('byform')"
  64. size="large"
  65. :loading="submitLoading"
  66. >
  67. 确 定
  68. </el-button>
  69. </template>
  70. </el-dialog>
  71. <el-dialog
  72. title="Excel导入"
  73. v-model="openExcelDialog"
  74. width="400"
  75. v-loading="loading"
  76. >
  77. <template #footer>
  78. <el-button @click="openExcelDialog = false" size="large"
  79. >取 消</el-button
  80. >
  81. <el-button
  82. type="primary"
  83. @click="submitExcel()"
  84. size="large"
  85. :loading="submitLoading"
  86. >
  87. 确 定
  88. </el-button>
  89. </template>
  90. </el-dialog>
  91. </div>
  92. </template>
  93. <script setup>
  94. /* eslint-disable vue/no-unused-components */
  95. import { ElMessage, ElMessageBox } from "element-plus";
  96. import byTable from "@/components/byTable/index";
  97. import byForm from "@/components/byForm/index";
  98. import Cookies from "js-cookie";
  99. import { computed, defineComponent, ref } from "vue";
  100. const loading = ref(false);
  101. const submitLoading = ref(false);
  102. const sourceList = ref({
  103. data: [],
  104. pagination: {
  105. total: 3,
  106. pageNum: 1,
  107. pageSize: 10,
  108. type: "",
  109. productClassifyId: "",
  110. keyword: "",
  111. definition: "2",
  112. },
  113. });
  114. let dialogVisible = ref(false);
  115. let openExcelDialog = ref(false);
  116. let modalType = ref("add");
  117. let rules = ref({
  118. productClassifyId: [
  119. { required: true, message: "请选择物料分类", trigger: "change" },
  120. ],
  121. type: [{ required: true, message: "请选择物料类型", trigger: "change" }],
  122. // name: [{ required: true, message: "请输入物料名称", trigger: "blur" }],
  123. // unit: [{ required: true, message: "请选择单位", trigger: "change" }],
  124. });
  125. const { proxy } = getCurrentInstance();
  126. const selectConfig = computed(() => {
  127. return [
  128. {
  129. label: "打款状态",
  130. prop: "paymentStatus",
  131. data: paymentType.value,
  132. },
  133. ];
  134. });
  135. const config = computed(() => {
  136. return [
  137. {
  138. attrs: {
  139. label: "归属公司",
  140. prop: "corporationName",
  141. },
  142. },
  143. {
  144. attrs: {
  145. label: "归属部门",
  146. prop: "deptName",
  147. },
  148. },
  149. {
  150. attrs: {
  151. label: "付款类型",
  152. prop: "type",
  153. },
  154. render(type) {
  155. return proxy.dictDataEcho(type, dictsData.payment_status);
  156. },
  157. },
  158. {
  159. attrs: {
  160. label: "申请人",
  161. prop: "userName",
  162. },
  163. },
  164. {
  165. attrs: {
  166. label: "申请时间",
  167. prop: "createTime",
  168. },
  169. },
  170. {
  171. attrs: {
  172. label: "用款时间",
  173. prop: "paymentTime",
  174. },
  175. },
  176. {
  177. attrs: {
  178. label: "金额",
  179. prop: "amount",
  180. },
  181. },
  182. {
  183. attrs: {
  184. label: "款项说明",
  185. prop: "paymentRemark",
  186. },
  187. },
  188. {
  189. attrs: {
  190. label: "打款状态",
  191. prop: "status",
  192. },
  193. render(status) {
  194. return proxy.dictValueLabel(status, paymentType.value);
  195. },
  196. },
  197. {
  198. attrs: {
  199. label: "操作",
  200. width: "200",
  201. align: "right",
  202. },
  203. // 渲染 el-button,一般用在最后一列。
  204. renderHTML(row) {
  205. return [
  206. {
  207. attrs: {
  208. label: "打款",
  209. type: "primary",
  210. text: true,
  211. },
  212. el: "button",
  213. click() {
  214. formOption.disabled = false;
  215. getDtl(row);
  216. },
  217. },
  218. {
  219. attrs: {
  220. label: "查看",
  221. type: "primary",
  222. text: true,
  223. },
  224. el: "button",
  225. click() {
  226. formOption.disabled = true;
  227. getDtl(row);
  228. },
  229. },
  230. ];
  231. },
  232. },
  233. ];
  234. });
  235. let formData = reactive({
  236. data: {},
  237. });
  238. const formOption = reactive({
  239. inline: true,
  240. labelWidth: 100,
  241. itemWidth: 100,
  242. rules: [],
  243. disabled: false,
  244. });
  245. const byform = ref(null);
  246. const treeListData = ref([]);
  247. const formConfig = computed(() => {
  248. return [
  249. {
  250. type: "title",
  251. label: "请款信息",
  252. },
  253. {
  254. type: "input",
  255. prop: "businessManagementName",
  256. label: "付款账户",
  257. disabled: true,
  258. },
  259. {
  260. type: "input",
  261. prop: "incomeAmount",
  262. label: "请款金额",
  263. disabled: true,
  264. },
  265. {
  266. type: "input",
  267. prop: "paymentMethod",
  268. label: "付款方式",
  269. disabled: true,
  270. },
  271. {
  272. type: "input",
  273. prop: "name",
  274. label: "户名",
  275. disabled: true,
  276. },
  277. {
  278. type: "input",
  279. prop: "accountOpening",
  280. label: "银行账号",
  281. disabled: true,
  282. },
  283. {
  284. type: "input",
  285. prop: "openingBank",
  286. label: "开户银行",
  287. disabled: true,
  288. },
  289. {
  290. type: "input",
  291. prop: "interbankNumber",
  292. label: "联行号 / SWIFT Code",
  293. disabled: true,
  294. },
  295. {
  296. type: "input",
  297. prop: "remark",
  298. label: "摘要",
  299. disabled: true,
  300. },
  301. {
  302. type: "title",
  303. title: "付款信息",
  304. },
  305. {
  306. type: "select",
  307. prop: "accountManagementId",
  308. label: "付款账户",
  309. required: true,
  310. isLoad: {
  311. url: "/accountManagement/page",
  312. req: {
  313. pageNum: 1,
  314. pageSize: 9999,
  315. },
  316. labelKey: "name",
  317. labelVal: "id",
  318. method: "post",
  319. resUrl: "rows",
  320. },
  321. },
  322. {
  323. type: "selectInput",
  324. label: "付款金额",
  325. itemWidth: 60,
  326. prop: "amount",
  327. data: [],
  328. placeholder: "请输入",
  329. selectPlaceholder: "币种",
  330. selectProp: "currency",
  331. disabled: true,
  332. },
  333. {
  334. type: "date",
  335. itemType: "datetime",
  336. prop: "expensesTime",
  337. label: "打款时间",
  338. format: "YYYY-MM-DD HH:mm:ss",
  339. },
  340. {
  341. type: "input",
  342. prop: "remark",
  343. label: "摘要",
  344. },
  345. // {
  346. // type: 'upload',
  347. // prop: 'upload',
  348. // label: '摘要',
  349. // },
  350. // {
  351. // type: 'slot',
  352. // slotName: 'productPic',
  353. // prop: 'fileList',
  354. // label: '上传附件',
  355. // },
  356. ];
  357. });
  358. const newPassword = () => {
  359. formData.data.password = generatePassword();
  360. };
  361. const generatePassword = () => {
  362. var length = 12,
  363. charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
  364. password = "";
  365. for (var i = 0, n = charset.length; i < length; ++i) {
  366. password += charset.charAt(Math.floor(Math.random() * n));
  367. }
  368. return password;
  369. };
  370. const getList = async (req) => {
  371. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  372. loading.value = true;
  373. proxy
  374. .post("/accountPayment/page", sourceList.value.pagination)
  375. .then((message) => {
  376. sourceList.value.data = message.rows;
  377. sourceList.value.pagination.total = message.total;
  378. setTimeout(() => {
  379. loading.value = false;
  380. }, 200);
  381. });
  382. };
  383. const uploadData = ref({});
  384. const fileList = ref([]);
  385. const paymentType = ref([
  386. {
  387. label: "已打款",
  388. value: 10,
  389. },
  390. {
  391. label: "未打款",
  392. value: 20,
  393. },
  394. ]);
  395. const fileListCopy = ref([]);
  396. let dictsData = reactive({
  397. payment_status: [],
  398. account_currency: [],
  399. });
  400. proxy.getDict(["payment_status", "account_currency"]).then((res) => {
  401. dictsData = res;
  402. formConfig.value[11].data = res.account_currency.map((item) => {
  403. return {
  404. label: item.dictValue,
  405. value: item.dictKey,
  406. };
  407. });
  408. });
  409. const openModal = () => {
  410. dialogVisible.value = true;
  411. modalType.value = "add";
  412. formData.data = {
  413. definition: "2",
  414. fileList: [],
  415. type: "1",
  416. };
  417. fileList.value = [];
  418. fileListCopy.value = [];
  419. };
  420. const openExcel = () => {
  421. openExcelDialog.value = true;
  422. };
  423. const submitExcel = () => {
  424. openExcelDialog.value = false;
  425. };
  426. const selection = ref({
  427. data: [],
  428. });
  429. const select = (_selection, row) => {
  430. selection.value.data = _selection;
  431. console.log(_selection.length);
  432. };
  433. const submitForm = () => {
  434. byform.value.handleSubmit((valid) => {
  435. submitLoading.value = true;
  436. proxy.post("/accountPayment/add", formData.data).then(
  437. (res) => {
  438. ElMessage({
  439. message: "打款成功",
  440. type: "success",
  441. });
  442. dialogVisible.value = false;
  443. submitLoading.value = false;
  444. getList();
  445. },
  446. (err) => {
  447. submitLoading.value = false;
  448. }
  449. );
  450. });
  451. };
  452. const getTreeList = () => {
  453. proxy
  454. .post("/productClassify/tree", {
  455. parentId: "",
  456. name: "",
  457. definition: "2",
  458. })
  459. .then((message) => {
  460. treeListData.value = message;
  461. formConfig.value[0].data = message;
  462. });
  463. };
  464. const getDtl = (row) => {
  465. modalType.value = "edit";
  466. proxy.post("/accountPayment/detail", { id: row.id }).then((res) => {
  467. formData.data = res;
  468. formData.data.amount = formData.data.incomeAmount;
  469. dialogVisible.value = true;
  470. });
  471. };
  472. getTreeList();
  473. getList();
  474. const handleBeforeUpload = async (file) => {
  475. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  476. uploadData.value = res.uploadBody;
  477. fileListCopy.value.push({
  478. id: res.id,
  479. fileName: res.fileName,
  480. path: res.fileUrl,
  481. url: res.fileUrl,
  482. uid: file.uid,
  483. });
  484. };
  485. const handleSuccess = (res, file, files) => {
  486. // 查当前file的index值去赋值对应的copy变量的值
  487. // let uid = file.uid;
  488. // const index = fileList.value.findIndex((x) => x.uid === uid);
  489. // fileListCopy.value[index].uid = uid;
  490. };
  491. const handleRemove = (file) => {
  492. const index = fileListCopy.value.findIndex(
  493. (x) => x.uid === file.uid || x.id === file.id
  494. );
  495. fileListCopy.value.splice(index, 1);
  496. };
  497. const handleClickFile = (file) => {
  498. window.open(file.fileUrl, "_blank");
  499. };
  500. </script>
  501. <style lang="scss" scoped>
  502. .user {
  503. padding: 20px;
  504. }
  505. .pic {
  506. object-fit: contain;
  507. width: 50px;
  508. height: 50px;
  509. cursor: pointer;
  510. vertical-align: middle;
  511. }
  512. </style>