index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  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. render(type) {
  156. return proxy.dictDataEcho(type, dictsData.value.payment_type)
  157. },
  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: 'total',
  182. },
  183. },
  184. {
  185. attrs: {
  186. label: '款项说明',
  187. prop: 'paymentRemarks',
  188. },
  189. },
  190. {
  191. attrs: {
  192. label: '打款状态',
  193. prop: 'status',
  194. },
  195. },
  196. {
  197. attrs: {
  198. label: '操作',
  199. width: '200',
  200. align: 'right',
  201. },
  202. // 渲染 el-button,一般用在最后一列。
  203. renderHTML(row) {
  204. return [
  205. {
  206. attrs: {
  207. label: '查看',
  208. type: 'primary',
  209. text: true,
  210. },
  211. el: 'button',
  212. click() {
  213. getDtl(row)
  214. },
  215. },
  216. {
  217. attrs: {
  218. label: '删除',
  219. type: 'danger',
  220. text: true,
  221. },
  222. el: 'button',
  223. click() {
  224. // 弹窗提示是否删除
  225. ElMessageBox.confirm(
  226. '此操作将永久删除该数据, 是否继续?',
  227. '提示',
  228. {
  229. confirmButtonText: '确定',
  230. cancelButtonText: '取消',
  231. type: 'warning',
  232. }
  233. ).then(() => {
  234. // 删除
  235. proxy
  236. .post('/productInfo/delete', {
  237. id: row.id,
  238. })
  239. .then((res) => {
  240. ElMessage({
  241. message: '删除成功',
  242. type: 'success',
  243. })
  244. getList()
  245. })
  246. })
  247. },
  248. },
  249. ]
  250. },
  251. },
  252. ]
  253. })
  254. let formData = reactive({
  255. data: {},
  256. })
  257. const formOption = reactive({
  258. inline: true,
  259. labelWidth: 100,
  260. itemWidth: 100,
  261. rules: [],
  262. })
  263. const byform = ref(null)
  264. const treeListData = ref([])
  265. const formConfig = computed(() => {
  266. return [
  267. {
  268. type: 'title',
  269. label: '请款信息',
  270. },
  271. {
  272. type: 'input',
  273. prop: 'businessManagementName',
  274. label: '付款账户',
  275. readonly: true,
  276. },
  277. {
  278. type: 'input',
  279. prop: 'incomeAmount',
  280. label: '请款金额',
  281. readonly: true,
  282. },
  283. {
  284. type: 'input',
  285. prop: 'paymentMethod',
  286. label: '付款方式',
  287. readonly: true,
  288. },
  289. {
  290. type: 'input',
  291. prop: 'name',
  292. label: '户名',
  293. readonly: true,
  294. },
  295. {
  296. type: 'input',
  297. prop: 'accountOpening',
  298. label: '银行账号',
  299. readonly: true,
  300. },
  301. {
  302. type: 'input',
  303. prop: 'openingBank',
  304. label: '开户银行',
  305. readonly: true,
  306. },
  307. {
  308. type: 'input',
  309. prop: 'interbankNumber',
  310. label: '联行号',
  311. readonly: true,
  312. },
  313. {
  314. type: 'input',
  315. prop: 'remark',
  316. label: '摘要',
  317. readonly: true,
  318. },
  319. {
  320. type: 'title',
  321. label: '付款信息',
  322. },
  323. {
  324. type: 'select',
  325. prop: 'accountManagementId',
  326. label: '付款账户',
  327. required: true,
  328. isLoad: {
  329. url: '/accountManagement/page',
  330. req: {
  331. pageNum: 1,
  332. pageSize: 9999,
  333. },
  334. labelKey: 'name',
  335. labelVal: 'id',
  336. method: 'post',
  337. resUrl: 'rows',
  338. },
  339. },
  340. {
  341. type: 'selectInput',
  342. label: '付款金额',
  343. itemWidth: 60,
  344. prop: 'amount',
  345. data: [],
  346. placeholder: '请输入',
  347. selectPlaceholder: '币种',
  348. selectProp: 'businessCurrency',
  349. },
  350. {
  351. type: 'date',
  352. prop: 'expensesTime',
  353. label: '打款时间',
  354. },
  355. {
  356. type: 'input',
  357. prop: 'remark',
  358. label: '摘要',
  359. },
  360. {
  361. type: 'slot',
  362. slotName: 'productPic',
  363. prop: 'fileList',
  364. label: '上传附件',
  365. },
  366. ]
  367. })
  368. const newPassword = () => {
  369. formData.data.password = generatePassword()
  370. }
  371. const generatePassword = () => {
  372. var length = 12,
  373. charset =
  374. 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
  375. password = ''
  376. for (var i = 0, n = charset.length; i < length; ++i) {
  377. password += charset.charAt(Math.floor(Math.random() * n))
  378. }
  379. return password
  380. }
  381. const getList = async (req) => {
  382. sourceList.value.pagination = { ...sourceList.value.pagination, ...req }
  383. loading.value = true
  384. proxy
  385. .post('/accountPayment/page', sourceList.value.pagination)
  386. .then((message) => {
  387. console.log(message)
  388. sourceList.value.data = message.rows
  389. sourceList.value.pagination.total = message.total
  390. setTimeout(() => {
  391. loading.value = false
  392. }, 200)
  393. })
  394. }
  395. const uploadData = ref({})
  396. const fileList = ref([])
  397. const fileListCopy = ref([])
  398. let dictsData = reactive({})
  399. proxy
  400. .getDict(['payment_status', 'payment_type','account_currency'])
  401. .then((res) => {
  402. dictsData = res
  403. console.log(res)
  404. formConfig.value[11].data = res.account_currency.map(item => {
  405. return {
  406. label: item.dictValue,
  407. value: item.dictKey,
  408. }
  409. })
  410. console.log(formConfig.value[11].data)
  411. })
  412. const openModal = () => {
  413. dialogVisible.value = true
  414. modalType.value = 'add'
  415. formData.data = {
  416. definition: '2',
  417. fileList: [],
  418. type: '1',
  419. }
  420. fileList.value = []
  421. fileListCopy.value = []
  422. }
  423. const openExcel = () => {
  424. openExcelDialog.value = true
  425. }
  426. const submitExcel = () => {
  427. openExcelDialog.value = false
  428. }
  429. const selection = ref({
  430. data: [],
  431. })
  432. const select = (_selection, row) => {
  433. selection.value.data = _selection
  434. console.log(_selection.length)
  435. }
  436. const submitForm = () => {
  437. console.log(byform.value)
  438. byform.value.handleSubmit((valid) => {
  439. submitLoading.value = true
  440. proxy.post('/accountPayment/add', formData.data).then(
  441. (res) => {
  442. ElMessage({
  443. message: '打款成功',
  444. type: 'success',
  445. })
  446. dialogVisible.value = false
  447. submitLoading.value = false
  448. getList()
  449. },
  450. (err) => {
  451. submitLoading.value = false
  452. }
  453. )
  454. })
  455. }
  456. const getTreeList = () => {
  457. proxy
  458. .post('/productClassify/tree', {
  459. parentId: '',
  460. name: '',
  461. definition: '2',
  462. })
  463. .then((message) => {
  464. treeListData.value = message
  465. formConfig.value[0].data = message
  466. })
  467. }
  468. const getDtl = (row) => {
  469. modalType.value = 'edit'
  470. proxy.post('/accountPayment/detail', { id: row.id }).then((res) => {
  471. formData.data = res
  472. dialogVisible.value = true
  473. })
  474. }
  475. getTreeList()
  476. getList()
  477. const handleBeforeUpload = async (file) => {
  478. const res = await proxy.post('/fileInfo/getSing', { fileName: file.name })
  479. uploadData.value = res.uploadBody
  480. fileListCopy.value.push({
  481. id: res.id,
  482. fileName: res.fileName,
  483. path: res.fileUrl,
  484. url: res.fileUrl,
  485. uid: file.uid,
  486. })
  487. }
  488. const handleSuccess = (res, file, files) => {
  489. // 查当前file的index值去赋值对应的copy变量的值
  490. // let uid = file.uid;
  491. // const index = fileList.value.findIndex((x) => x.uid === uid);
  492. // fileListCopy.value[index].uid = uid;
  493. }
  494. const handleRemove = (file) => {
  495. const index = fileListCopy.value.findIndex(
  496. (x) => x.uid === file.uid || x.id === file.id
  497. )
  498. fileListCopy.value.splice(index, 1)
  499. }
  500. const handleClickFile = (file) => {
  501. window.open(file.fileUrl, '_blank')
  502. }
  503. </script>
  504. <style lang="scss" scoped>
  505. .user {
  506. padding: 20px;
  507. }
  508. .pic {
  509. object-fit: contain;
  510. width: 50px;
  511. height: 50px;
  512. cursor: pointer;
  513. vertical-align: middle;
  514. }
  515. </style>