index.vue 11 KB

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