index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. <template>
  2. <div class="tenant">
  3. <!-- <Banner /> -->
  4. <div class="content">
  5. <byTable
  6. :source="sourceList.data"
  7. :pagination="sourceList.pagination"
  8. :config="config"
  9. :loading="loading"
  10. highlight-current-row
  11. :selectConfig="selectConfig"
  12. :table-events="{
  13. //element talbe事件都能传
  14. select: select,
  15. }"
  16. :action-list="[]"
  17. @get-list="getList"
  18. >
  19. <template #money="{ item }">
  20. {{ item.currency }} {{ moneyFormat(item.amount) }}
  21. </template>
  22. </byTable>
  23. </div>
  24. <el-dialog
  25. title="认领"
  26. v-model="dialogVisible"
  27. width="500"
  28. v-loading="loading"
  29. >
  30. <byForm
  31. :formConfig="formConfig"
  32. :formOption="formOption"
  33. v-model="formData.data"
  34. :rules="rules"
  35. ref="byform"
  36. >
  37. <template #detail>
  38. <div style="width: 100%">
  39. <el-button
  40. type="primary"
  41. style="margin-bottom: 10px"
  42. @click="dialogVisibleOne = true"
  43. >选择合同</el-button
  44. >
  45. <el-table :data="formData.data.claimContractList">
  46. <el-table-column prop="contractCode" label="合同编码" />
  47. <el-table-column prop="money" label="关联金额" min-width="150">
  48. <template #default="{ row, $index }">
  49. <el-form-item
  50. :prop="'claimContractList.' + $index + '.money'"
  51. :rules="rules.money"
  52. :inline-message="true"
  53. >
  54. <el-input-number
  55. v-model="row.money"
  56. :precision="4"
  57. :controls="false"
  58. :min="0"
  59. />
  60. </el-form-item>
  61. </template>
  62. </el-table-column>
  63. <el-table-column prop="zip" label="操作" width="100">
  64. <template #default="{ $index }">
  65. <el-button type="primary" link @click="handleRemove($index)"
  66. >删除</el-button
  67. >
  68. </template>
  69. </el-table-column>
  70. </el-table>
  71. </div>
  72. </template>
  73. <template #fileSlot>
  74. <div>
  75. <el-upload
  76. v-model:fileList="fileList"
  77. :show-file-list="false"
  78. class="upload-demo"
  79. action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
  80. :data="uploadData"
  81. :on-preview="handlePreview"
  82. :on-remove="handleRemove"
  83. :on-success="handleSuccess"
  84. :before-upload="handleBeforeUpload"
  85. >
  86. <el-button type="primary">选择</el-button>
  87. </el-upload>
  88. <div>
  89. <div style="margin-top: 15px">
  90. <el-tag
  91. style="margin-right: 10px"
  92. class="ml-2"
  93. type="info"
  94. v-for="(item, index) in fileListCopy"
  95. :key="index"
  96. closable
  97. @close="handleClose(index)"
  98. >{{ item.fileName }}</el-tag
  99. >
  100. </div>
  101. </div>
  102. </div>
  103. </template>
  104. </byForm>
  105. <template #footer>
  106. <el-button @click="dialogVisible = false" size="large">取 消</el-button>
  107. <el-button
  108. type="primary"
  109. @click="submitForm('byform')"
  110. size="large"
  111. :loading="submitLoading"
  112. >
  113. 确 定
  114. </el-button>
  115. </template>
  116. </el-dialog>
  117. <el-dialog
  118. title="合同选择"
  119. v-model="dialogVisibleOne"
  120. width="80%"
  121. v-loading="loading"
  122. destroy-on-close
  123. >
  124. <ContractSelect
  125. @handleSelectContrct="handleSelectContrct"
  126. ></ContractSelect>
  127. </el-dialog>
  128. </div>
  129. </template>
  130. <script setup>
  131. /* eslint-disable vue/no-unused-components */
  132. import { ElMessage, ElMessageBox } from "element-plus";
  133. import byTable from "@/components/byTable/index";
  134. import byForm from "@/components/byForm/index";
  135. import { computed, defineComponent, ref } from "vue";
  136. import useUserStore from "@/store/modules/user";
  137. import { getToken } from "@/utils/auth";
  138. import ContractSelect from "@/views/salesMange/saleContract/contractSelect/index";
  139. const headers = ref({ Authorization: "Bearer " + getToken() });
  140. const uploadData = ref({});
  141. let fileList = ref([]);
  142. let fileListCopy = ref([]);
  143. const loading = ref(false);
  144. const submitLoading = ref(false);
  145. const sourceList = ref({
  146. data: [],
  147. pagination: {
  148. total: 3,
  149. pageNum: 1,
  150. pageSize: 10,
  151. type: 1,
  152. dataType: "1",
  153. },
  154. });
  155. let dialogVisible = ref(false);
  156. let dialogVisibleOne = ref(false);
  157. let modalType = ref("add");
  158. let rules = ref({
  159. money: [{ required: true, message: "请输入关联金额", trigger: "blur" }],
  160. });
  161. const { proxy } = getCurrentInstance();
  162. const selectConfig = reactive([
  163. {
  164. label: "认领状态",
  165. prop: "isClaim",
  166. data: [
  167. {
  168. label: "未认领",
  169. value: "0",
  170. },
  171. {
  172. label: "已认领",
  173. value: "1",
  174. },
  175. ],
  176. },
  177. ]);
  178. const inboundType = ref([
  179. {
  180. label: "未入库",
  181. value: "0",
  182. },
  183. {
  184. label: "部分入库",
  185. value: "1",
  186. },
  187. {
  188. label: "入库完成",
  189. value: "2",
  190. },
  191. ]);
  192. const config = computed(() => {
  193. return [
  194. {
  195. attrs: {
  196. label: "账户名称",
  197. prop: "accountManagementName",
  198. },
  199. // render(type) {
  200. // return proxy.dictDataEcho(type, warehouseType.value);
  201. // },
  202. },
  203. {
  204. attrs: {
  205. label: "到账金额",
  206. prop: "amount",
  207. slot: "money",
  208. },
  209. },
  210. {
  211. attrs: {
  212. label: "到账时间",
  213. prop: "transactionTime",
  214. },
  215. },
  216. {
  217. attrs: {
  218. label: "对方账户名称",
  219. prop: "name",
  220. },
  221. },
  222. {
  223. attrs: {
  224. label: "对方开户银行",
  225. prop: "openingBank",
  226. },
  227. },
  228. {
  229. attrs: {
  230. label: "对方账号",
  231. prop: "accountOpening",
  232. },
  233. },
  234. {
  235. attrs: {
  236. label: "摘要",
  237. prop: "remarks",
  238. },
  239. },
  240. {
  241. attrs: {
  242. label: "认领状态",
  243. prop: "isClaim",
  244. },
  245. render(isClaim) {
  246. return isClaim == 1 ? "已认领" : isClaim == 0 ? "未认领" : "";
  247. },
  248. },
  249. {
  250. attrs: {
  251. label: "操作",
  252. width: "100",
  253. align: "right",
  254. },
  255. // 渲染 el-button,一般用在最后一列。
  256. renderHTML(row) {
  257. return [
  258. row.isClaim == 0
  259. ? {
  260. attrs: {
  261. label: "认领",
  262. type: "primary",
  263. text: true,
  264. bg: true,
  265. disabled: false,
  266. },
  267. el: "button",
  268. click() {
  269. getDtl(row);
  270. },
  271. }
  272. : {},
  273. row.isClaim == 1
  274. ? {
  275. attrs: {
  276. label: "取消认领",
  277. text: true,
  278. bg: true,
  279. type: "primary",
  280. disabled: false,
  281. style: {
  282. color: "#e6a23c",
  283. },
  284. },
  285. el: "button",
  286. click() {
  287. ElMessageBox.confirm("是否确定取消认领?", "提示", {
  288. confirmButtonText: "确定",
  289. cancelButtonText: "取消",
  290. type: "warning",
  291. }).then(() => {
  292. // 删除
  293. proxy
  294. .post("/claim/delete", {
  295. id: row.id,
  296. })
  297. .then((res) => {
  298. ElMessage({
  299. message: "操作成功",
  300. type: "success",
  301. });
  302. getList();
  303. });
  304. });
  305. },
  306. }
  307. : {},
  308. ];
  309. },
  310. },
  311. ];
  312. });
  313. let formData = reactive({
  314. data: {},
  315. treeData: [],
  316. });
  317. const formOption = reactive({
  318. inline: true,
  319. labelWidth: 100,
  320. itemWidth: 100,
  321. rules: [],
  322. });
  323. const byform = ref(null);
  324. const treeData = ref([]);
  325. const formConfig = reactive([
  326. {
  327. type: "title",
  328. title: "账户信息",
  329. },
  330. {
  331. type: "select",
  332. prop: "accountManagementName",
  333. label: "选择账户",
  334. required: true,
  335. disabled: true,
  336. },
  337. {
  338. type: "title",
  339. title: "交易信息",
  340. },
  341. {
  342. type: "date",
  343. itemType: "datetime",
  344. prop: "claimTime",
  345. label: "交易时间",
  346. disabled: true,
  347. },
  348. {
  349. type: "select",
  350. prop: "status",
  351. label: "交易金额",
  352. itemWidth: 30,
  353. disabled: true,
  354. data: [
  355. {
  356. label: "收入",
  357. value: "10",
  358. },
  359. {
  360. label: "支出",
  361. value: "20",
  362. },
  363. ],
  364. },
  365. {
  366. type: "selectInput",
  367. prop: "amount",
  368. selectProp: "currency",
  369. label: " ",
  370. itemWidth: 70,
  371. disabled: true,
  372. },
  373. // {
  374. // type: "select",
  375. // prop: "warehouseId",
  376. // label: "仓库名称",
  377. // itemWidth: 33,
  378. // isLoad: {
  379. // url: "/warehouse/page",
  380. // req: {
  381. // pageNum: 1,
  382. // pageSize: 9999,
  383. // },
  384. // labelKey: "name",
  385. // labelVal: "id",
  386. // method: "post",
  387. // resUrl: "rows",
  388. // },
  389. // },
  390. {
  391. type: "title",
  392. title: "认领信息",
  393. },
  394. {
  395. type: "slot",
  396. slotName: "detail",
  397. label: "",
  398. },
  399. {
  400. type: "slot",
  401. slotName: "fileSlot",
  402. label: "上传附件",
  403. },
  404. ]);
  405. const getList = async (req) => {
  406. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  407. loading.value = true;
  408. proxy
  409. .post("/accountRunningWater/page", sourceList.value.pagination)
  410. .then((message) => {
  411. console.log(message);
  412. sourceList.value.data = message.rows;
  413. // .map((x) => ({
  414. // ...x,
  415. // ...JSON.parse(x.victoriatouristJson),
  416. // }));
  417. sourceList.value.pagination.total = message.total;
  418. setTimeout(() => {
  419. loading.value = false;
  420. }, 200);
  421. });
  422. };
  423. const openModal = () => {
  424. dialogVisible.value = true;
  425. modalType.value = "add";
  426. formData.data = {};
  427. };
  428. const submitForm = () => {
  429. byform.value.handleSubmit((valid) => {
  430. const list = formData.data.claimContractList;
  431. if (!(list.length > 0)) {
  432. return ElMessage({
  433. message: `请添加认领信息!`,
  434. type: "info",
  435. });
  436. }
  437. for (let i = 0; i < list.length; i++) {
  438. const e = list[i];
  439. if (!(e.money > 0)) {
  440. return ElMessage({
  441. message: "关联金额不能为0!",
  442. type: "info",
  443. });
  444. }
  445. }
  446. const total = list.reduce((total, x) => (total += Number(x.money)), 0);
  447. if (Number(formData.data.amount) !== total) {
  448. return ElMessage({
  449. message: "认领金额总合和交易金额需一致!",
  450. type: "info",
  451. });
  452. }
  453. formData.data.fileList =
  454. fileListCopy.value.map((x) => ({
  455. id: x.id,
  456. fileName: x.fileName,
  457. })) || [];
  458. submitLoading.value = true;
  459. proxy.post("/claim/add", formData.data).then(
  460. (res) => {
  461. ElMessage({
  462. message: "操作成功",
  463. type: "success",
  464. });
  465. dialogVisible.value = false;
  466. submitLoading.value = false;
  467. getList();
  468. },
  469. (err) => (submitLoading.value = false)
  470. );
  471. });
  472. };
  473. const getDtl = (row) => {
  474. modalType.value = "edit";
  475. dialogVisible.value = true;
  476. formData.data = {
  477. businessId: row.id,
  478. status: row.status + "",
  479. currency: row.currency,
  480. amount: row.amount,
  481. accountManagementId: row.accountManagementId,
  482. accountManagementName: row.accountManagementName,
  483. claimTime: proxy.parseTime(new Date()),
  484. claimContractList: [],
  485. };
  486. dialogVisible.value = true;
  487. };
  488. const warehouseType = ref([]);
  489. const getDict = () => {
  490. // // 币种数据
  491. proxy
  492. .post("/dictTenantData/page", {
  493. pageNum: 1,
  494. pageSize: 999,
  495. tenantId: useUserStore().user.tenantId,
  496. dictCode: "warehouse_type",
  497. })
  498. .then((res) => {
  499. warehouseType.value = res.rows;
  500. formConfig[0].data = res.rows.map((x) => ({
  501. label: x.dictValue,
  502. value: x.dictKey,
  503. }));
  504. });
  505. };
  506. const handleBeforeUpload = async (file) => {
  507. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  508. uploadData.value = res.uploadBody;
  509. fileListCopy.value.push({
  510. id: res.id,
  511. fileName: res.fileName,
  512. path: res.fileUrl,
  513. url: res.fileUrl,
  514. uid: file.uid,
  515. });
  516. };
  517. const handleClose = (index) => {
  518. // if (fileListCopy.value.length === 1) {
  519. // return ElMessage({
  520. // message: "最后一个附件啦!",
  521. // type: "info",
  522. // });
  523. // }
  524. fileList.value.splice(index, 1);
  525. fileListCopy.value.splice(index, 1);
  526. };
  527. const handleRemove = (index) => {
  528. formData.data.claimContractList.splice(index, 1);
  529. return ElMessage({
  530. message: "删除成功",
  531. type: "success",
  532. });
  533. };
  534. const handleSelectContrct = (row) => {
  535. const flag = formData.data.claimContractList.some(
  536. (x) => x.contractId === row.id
  537. );
  538. if (flag)
  539. return ElMessage({
  540. message: "该合同已选择",
  541. type: "info",
  542. });
  543. formData.data.claimContractList.push({
  544. contractId: row.id,
  545. contractCode: row.code,
  546. money: 0,
  547. });
  548. return ElMessage({
  549. message: "选择成功",
  550. type: "success",
  551. });
  552. };
  553. getList();
  554. getDict();
  555. onMounted(() => {});
  556. </script>
  557. <style lang="scss" scoped>
  558. .tenant {
  559. padding: 20px;
  560. }
  561. </style>