index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. <template>
  2. <div class="pageIndexClass">
  3. <div class="content">
  4. <byTable :source="sourceList.data" :pagination="sourceList.pagination" :config="config" :loading="loading" highlight-current-row :action-list="[
  5. {
  6. text: '添加账户',
  7. action: () => openModal('add'),
  8. },
  9. ]" @get-list="getList">
  10. </byTable>
  11. </div>
  12. <el-dialog :title="modalType == 'add' ? '添加账户' : '编辑账户'" v-if="dialogVisible" v-model="dialogVisible" width="60%">
  13. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit" v-loading="loadingDialog">
  14. <template #balance>
  15. <div style="width: 100%">
  16. <el-button type="primary" @click="clickBalance">添加</el-button>
  17. <el-table :data="formData.data.accountRemainderList" style="width: 100%; margin-top: 16px">
  18. <el-table-column label="币种">
  19. <template #default="{ row, $index }">
  20. <el-form-item :prop="'accountRemainderList.' + $index + '.currency'" :rules="rules.currency" :inline-message="true"
  21. class="margin-b-0 wid100">
  22. <el-select v-model="row.currency" placeholder="请选择币种" style="width: 100%" :disabled="row.id">
  23. <el-option v-for="item in accountCurrency" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
  24. </el-select>
  25. </el-form-item>
  26. </template>
  27. </el-table-column>
  28. <el-table-column label="余额">
  29. <template #default="{ row, $index }">
  30. <el-form-item :prop="'accountRemainderList.' + $index + '.remainder'" :rules="rules.remainder" :inline-message="true"
  31. class="margin-b-0 wid100">
  32. <el-input-number onmousewheel="return false;" v-model="row.remainder" placeholder="请输入余额" style="width: 100%" :precision="2"
  33. :controls="false" :min="0" :disabled="row.id" />
  34. </el-form-item>
  35. </template>
  36. </el-table-column>
  37. <el-table-column label="操作" width="80">
  38. <template #default="{ row, $index }">
  39. <el-button type="primary" link @click="handleRemove($index)" v-if="!row.id">删除</el-button>
  40. </template>
  41. </el-table-column>
  42. </el-table>
  43. </div>
  44. </template>
  45. </byForm>
  46. <template #footer>
  47. <el-button @click="dialogVisible = false" size="default">取 消</el-button>
  48. <el-button type="primary" @click="submitForm()" size="default">确 定</el-button>
  49. </template>
  50. </el-dialog>
  51. </div>
  52. </template>
  53. <script setup>
  54. import { computed, ref } from "vue";
  55. import byTable from "@/components/byTable/index";
  56. import byForm from "@/components/byForm/index";
  57. import useUserStore from "@/store/modules/user";
  58. import { ElMessage, ElMessageBox } from "element-plus";
  59. const { proxy } = getCurrentInstance();
  60. const accountCurrency = ref([]);
  61. const sourceList = ref({
  62. data: [],
  63. pagination: {
  64. total: 0,
  65. pageNum: 1,
  66. pageSize: 10,
  67. keyword: "",
  68. },
  69. });
  70. const loading = ref(false);
  71. const config = computed(() => {
  72. return [
  73. {
  74. attrs: {
  75. label: "企业信息",
  76. prop: "corporationName",
  77. },
  78. },
  79. {
  80. attrs: {
  81. label: "类型",
  82. prop: "type",
  83. },
  84. render(val) {
  85. return proxy.dictValueLabel(val, typeData.value);
  86. },
  87. },
  88. {
  89. attrs: {
  90. label: "账户别名",
  91. prop: "alias",
  92. },
  93. },
  94. {
  95. attrs: {
  96. label: "开户银行",
  97. prop: "openingBank",
  98. },
  99. },
  100. {
  101. attrs: {
  102. label: "账户名",
  103. prop: "name",
  104. },
  105. },
  106. {
  107. attrs: {
  108. label: "账号",
  109. prop: "accountOpening",
  110. },
  111. },
  112. {
  113. attrs: {
  114. label: "联行号",
  115. prop: "interbankNumber",
  116. },
  117. },
  118. {
  119. attrs: {
  120. label: "操作",
  121. width: "120",
  122. align: "center",
  123. },
  124. renderHTML(row) {
  125. return [
  126. {
  127. attrs: {
  128. label: "修改",
  129. type: "primary",
  130. text: true,
  131. },
  132. el: "button",
  133. click() {
  134. update(row);
  135. },
  136. },
  137. {
  138. attrs: {
  139. label: "删除",
  140. type: "primary",
  141. text: true,
  142. },
  143. el: "button",
  144. click() {
  145. ElMessageBox.confirm(
  146. "此操作将永久删除该数据, 是否继续?",
  147. "提示",
  148. {
  149. confirmButtonText: "确定",
  150. cancelButtonText: "取消",
  151. type: "warning",
  152. }
  153. ).then(() => {
  154. proxy
  155. .post("/accountManagement/delete", {
  156. id: row.id,
  157. })
  158. .then(() => {
  159. ElMessage({
  160. message: "删除成功",
  161. type: "success",
  162. });
  163. getList();
  164. });
  165. });
  166. },
  167. },
  168. ];
  169. },
  170. },
  171. ];
  172. });
  173. const corporationList = ref([]);
  174. const typeData = ref([
  175. {
  176. label: "公账",
  177. value: 10,
  178. },
  179. {
  180. label: "私账",
  181. value: 20,
  182. },
  183. ]);
  184. const getDict = () => {
  185. proxy
  186. .post("/dictTenantData/page", {
  187. pageNum: 1,
  188. pageSize: 999,
  189. dictCode: "account_currency",
  190. tenantId: useUserStore().user.tenantId,
  191. })
  192. .then((res) => {
  193. if (res.rows && res.rows.length > 0) {
  194. accountCurrency.value = res.rows;
  195. }
  196. });
  197. proxy
  198. .post("/corporation/page", { pageNum: 1, pageSize: 9999 })
  199. .then((res) => {
  200. corporationList.value = res.rows.map((item) => {
  201. return {
  202. ...item,
  203. label: item.name,
  204. value: item.id,
  205. };
  206. });
  207. });
  208. };
  209. const getList = async (req) => {
  210. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  211. loading.value = true;
  212. proxy
  213. .post("/accountManagement/page", sourceList.value.pagination)
  214. .then((res) => {
  215. sourceList.value.data = res.rows;
  216. sourceList.value.pagination.total = res.total;
  217. setTimeout(() => {
  218. loading.value = false;
  219. }, 200);
  220. });
  221. };
  222. getDict();
  223. getList();
  224. const modalType = ref("add");
  225. const dialogVisible = ref(false);
  226. const loadingDialog = ref(false);
  227. const submit = ref(null);
  228. const formOption = reactive({
  229. inline: true,
  230. labelWidth: 100,
  231. itemWidth: 100,
  232. rules: [],
  233. });
  234. const formConfig = computed(() => {
  235. return [
  236. {
  237. type: "title1",
  238. title: "基本信息",
  239. },
  240. {
  241. type: "select",
  242. prop: "corporationId",
  243. label: "企业信息",
  244. data: corporationList.value,
  245. itemWidth: 50,
  246. },
  247. {
  248. type: "select",
  249. prop: "type",
  250. label: "类型",
  251. data: typeData.value,
  252. itemWidth: 50,
  253. },
  254. {
  255. type: "input",
  256. prop: "alias",
  257. label: "账户别名",
  258. required: true,
  259. itemWidth: 50,
  260. itemType: "text",
  261. },
  262. {
  263. type: "input",
  264. prop: "openingBank",
  265. label: "开户银行",
  266. required: true,
  267. itemWidth: 50,
  268. itemType: "text",
  269. },
  270. {
  271. type: "input",
  272. prop: "name",
  273. label: "账户名",
  274. required: true,
  275. itemWidth: 50,
  276. itemType: "text",
  277. },
  278. {
  279. type: "input",
  280. prop: "accountOpening",
  281. label: "账号",
  282. required: true,
  283. itemWidth: 50,
  284. itemType: "text",
  285. },
  286. {
  287. type: "input",
  288. prop: "interbankNumber",
  289. label: "联行号",
  290. required: true,
  291. itemWidth: 50,
  292. itemType: "text",
  293. },
  294. {
  295. type: "number",
  296. prop: "taxPoints",
  297. label: "税点",
  298. precision: 2,
  299. min: 0,
  300. max: 100,
  301. controls: false,
  302. itemWidth: 50,
  303. },
  304. {
  305. type: "input",
  306. prop: "taxpayerCode",
  307. label: "纳税人识别号",
  308. itemWidth: 50,
  309. itemType: "text",
  310. },
  311. {
  312. type: "input",
  313. prop: "beneficiaryAddress",
  314. label: "地址",
  315. itemWidth: 50,
  316. itemType: "text",
  317. },
  318. {
  319. type: "input",
  320. prop: "beneficiaryTel",
  321. label: "电话",
  322. itemWidth: 50,
  323. itemType: "text",
  324. },
  325. {
  326. type: "input",
  327. prop: "jdSubjectCode",
  328. label: "银行科目代码",
  329. },
  330. {
  331. type: "input",
  332. prop: "jdSubjectName",
  333. label: "银行科目名称",
  334. },
  335. // {
  336. // type: "title1",
  337. // title: "外汇信息",
  338. // },
  339. // {
  340. // type: "input",
  341. // prop: "beneficiaryName",
  342. // label: "Beneficiary Name",
  343. // required: true,
  344. // itemType: "text",
  345. // itemWidth: 50,
  346. // },
  347. // {
  348. // type: "input",
  349. // prop: "beneficiaryBank",
  350. // label: "Beneficiary Bank",
  351. // required: true,
  352. // itemType: "text",
  353. // itemWidth: 50,
  354. // },
  355. // {
  356. // type: "input",
  357. // prop: "beneficiaryBankAddress",
  358. // label: "Beneficiary Bank Address",
  359. // required: true,
  360. // itemType: "text",
  361. // itemWidth: 50,
  362. // },
  363. // {
  364. // type: "input",
  365. // prop: "beneficiaryAccountNumber",
  366. // label: "Beneficiary Account Number",
  367. // required: true,
  368. // itemType: "text",
  369. // itemWidth: 50,
  370. // },
  371. // {
  372. // type: "input",
  373. // prop: "swiftCode",
  374. // label: "Swift Code",
  375. // required: true,
  376. // itemType: "text",
  377. // itemWidth: 50,
  378. // },
  379. // {
  380. // type: "input",
  381. // prop: "beneficiaryAddress",
  382. // label: "Beneficiary Address",
  383. // required: true,
  384. // itemType: "text",
  385. // itemWidth: 50,
  386. // },
  387. // {
  388. // type: "title1",
  389. // title: "账户余额",
  390. // },
  391. // {
  392. // type: "slot",
  393. // slotName: "balance",
  394. // label: "账户余额",
  395. // },
  396. ];
  397. });
  398. const rules = ref({
  399. alias: [{ required: true, message: "请输入账户别名", trigger: "blur" }],
  400. openingBank: [{ required: true, message: "请输入开户银行", trigger: "blur" }],
  401. name: [{ required: true, message: "请输入账户名", trigger: "blur" }],
  402. accountOpening: [{ required: true, message: "请输入账号", trigger: "blur" }],
  403. currency: [{ required: true, message: "请选择币种", trigger: "change" }],
  404. remainder: [{ required: true, message: "请输入账户余额", trigger: "blur" }],
  405. corporationId: [
  406. { required: true, message: "请选择业务公司", trigger: "change" },
  407. ],
  408. type: [{ required: true, message: "请选择类型", trigger: "change" }],
  409. taxPoints: [{ required: true, message: "请输入税点", trigger: "blur" }],
  410. });
  411. const formData = reactive({
  412. data: {
  413. accountRemainderList: [{ currency: "", remainder: undefined }],
  414. },
  415. });
  416. const openModal = (val) => {
  417. modalType.value = val;
  418. formData.data = {
  419. accountRemainderList: [{ currency: "", remainder: undefined }],
  420. };
  421. loadingDialog.value = false;
  422. dialogVisible.value = true;
  423. };
  424. const clickBalance = () => {
  425. if (
  426. formData.data.accountRemainderList &&
  427. formData.data.accountRemainderList.length > 0
  428. ) {
  429. formData.data.accountRemainderList.push({
  430. currency: "",
  431. remainder: undefined,
  432. });
  433. } else {
  434. formData.data.accountRemainderList = [
  435. { currency: "", remainder: undefined },
  436. ];
  437. }
  438. };
  439. const handleRemove = (index) => {
  440. formData.data.accountRemainderList.splice(index, 1);
  441. };
  442. const isRepeat = (arr) => {
  443. var hash = {};
  444. for (var i in arr) {
  445. if (hash[arr[i].currency]) return true;
  446. hash[arr[i].currency] = true;
  447. }
  448. return false;
  449. };
  450. const submitForm = () => {
  451. submit.value.handleSubmit(() => {
  452. loadingDialog.value = true;
  453. proxy.post("/accountManagement/" + modalType.value, formData.data).then(
  454. () => {
  455. ElMessage({
  456. message: modalType.value == "add" ? "添加成功" : "编辑成功",
  457. type: "success",
  458. });
  459. dialogVisible.value = false;
  460. getList();
  461. },
  462. (err) => {
  463. console.log(err);
  464. loadingDialog.value = false;
  465. }
  466. );
  467. // if (
  468. // formData.data.accountRemainderList &&
  469. // formData.data.accountRemainderList.length > 0
  470. // ) {
  471. // if (isRepeat(formData.data.accountRemainderList)) {
  472. // return ElMessage("请勿重复添加货币余额");
  473. // } else {
  474. // loadingDialog.value = true;
  475. // proxy.post("/accountManagement/" + modalType.value, formData.data).then(
  476. // () => {
  477. // ElMessage({
  478. // message: modalType.value == "add" ? "添加成功" : "编辑成功",
  479. // type: "success",
  480. // });
  481. // dialogVisible.value = false;
  482. // getList();
  483. // },
  484. // (err) => {
  485. // console.log(err);
  486. // loadingDialog.value = false;
  487. // }
  488. // );
  489. // }
  490. // } else {
  491. // return ElMessage("请添加至少一条账户余额");
  492. // }
  493. });
  494. };
  495. const update = (row) => {
  496. modalType.value = "edit";
  497. loadingDialog.value = true;
  498. proxy.post("/accountManagement/detail", { id: row.id }).then((res) => {
  499. res.accountRemainderList = res.accountRemainderList.map((item) => {
  500. return {
  501. id: item.id,
  502. currency: item.currency,
  503. remainder: item.remainder,
  504. };
  505. });
  506. formData.data = res;
  507. loadingDialog.value = false;
  508. });
  509. dialogVisible.value = true;
  510. };
  511. </script>
  512. <style lang="scss" scoped>
  513. .tenant {
  514. padding: 20px;
  515. }
  516. ::v-deep(.el-input-number .el-input__inner) {
  517. text-align: left;
  518. }
  519. </style>