index.vue 10 KB

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