index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. <template>
  2. <div class="tenant">
  3. <div class="content">
  4. <byTable
  5. :source="sourceList.data"
  6. :pagination="sourceList.pagination"
  7. :config="config"
  8. :loading="loading"
  9. :selectConfig="selectConfig"
  10. highlight-current-row
  11. :action-list="[
  12. {
  13. text: '添加流水',
  14. action: () => openModal('add'),
  15. },
  16. ]"
  17. @get-list="getList">
  18. <template #amount="{ item }">
  19. <div :style="'color: ' + (item.status === '10' ? '#04cb04;' : 'red;')">
  20. <span style="padding-right: 4px">{{ item.currency }}</span>
  21. <span v-if="item.status === '20'">-</span>
  22. <span>{{ moneyFormat(item.amount, 2) }}</span>
  23. </div>
  24. </template>
  25. </byTable>
  26. </div>
  27. <el-dialog :title="modalType == 'add' ? '添加流水' : '编辑流水'" v-if="dialogVisible" v-model="dialogVisible" width="600" v-loading="loadingDialog">
  28. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
  29. <template #transactionTime>
  30. <div>
  31. <el-date-picker v-model="formData.data.transactionTime" type="datetime" placeholder="请选择交易时间" value-format="YYYY-MM-DD HH:mm:ss" />
  32. </div>
  33. </template>
  34. <template #money>
  35. <div style="width: 100%">
  36. <el-row :gutter="10">
  37. <el-col :span="6">
  38. <el-form-item prop="status">
  39. <el-select v-model="formData.data.status" placeholder="请选择收支类型" style="width: 100%" @change="changeStatus()">
  40. <el-option v-for="item in status" :key="item.value" :label="item.label" :value="item.value" />
  41. </el-select>
  42. </el-form-item>
  43. </el-col>
  44. <el-col :span="6">
  45. <el-form-item prop="currency">
  46. <el-select v-model="formData.data.currency" placeholder="请选择币种" style="width: 100%">
  47. <el-option v-for="item in accountCurrency" :key="item.value" :label="item.label" :value="item.value" />
  48. </el-select>
  49. </el-form-item>
  50. </el-col>
  51. <el-col :span="12">
  52. <el-form-item prop="amount">
  53. <el-input-number v-model="formData.data.amount" placeholder="请输入金额" style="width: 100%" :precision="2" :controls="false" :min="0" />
  54. </el-form-item>
  55. </el-col>
  56. </el-row>
  57. </div>
  58. </template>
  59. <template #received>
  60. <div>
  61. <el-form-item prop="received">
  62. <el-radio-group v-model="formData.data.received">
  63. <el-radio v-for="item in received" :key="item.value" :label="item.value" border>{{ item.label }}</el-radio>
  64. </el-radio-group>
  65. </el-form-item>
  66. </div>
  67. </template>
  68. </byForm>
  69. <template #footer>
  70. <el-button @click="dialogVisible = false" size="large">取 消</el-button>
  71. <el-button type="primary" @click="submitForm()" size="large">确 定</el-button>
  72. </template>
  73. </el-dialog>
  74. </div>
  75. </template>
  76. <script setup>
  77. import { computed, ref } from "vue";
  78. import byTable from "@/components/byTable/index";
  79. import byForm from "@/components/byForm/index";
  80. import useUserStore from "@/store/modules/user";
  81. import { ElMessage, ElMessageBox } from "element-plus";
  82. import moment from "moment";
  83. const { proxy } = getCurrentInstance();
  84. const accountCurrency = ref([]);
  85. const accountList = ref([]);
  86. const status = ref([
  87. {
  88. label: "收入",
  89. value: "10",
  90. },
  91. {
  92. label: "支出",
  93. value: "20",
  94. },
  95. ]);
  96. const received = ref([
  97. {
  98. label: "是",
  99. value: "10",
  100. },
  101. {
  102. label: "否",
  103. value: "20",
  104. },
  105. ]);
  106. const sourceList = ref({
  107. data: [],
  108. pagination: {
  109. total: 0,
  110. pageNum: 1,
  111. pageSize: 10,
  112. keyword: "",
  113. accountManagementId: "",
  114. currency: "",
  115. status: "",
  116. },
  117. });
  118. const loading = ref(false);
  119. const selectConfig = computed(() => {
  120. return [
  121. {
  122. label: "收支类型",
  123. prop: "status",
  124. data: status.value,
  125. },
  126. {
  127. label: "资金账户",
  128. prop: "accountManagementId",
  129. data: accountList.value,
  130. },
  131. {
  132. label: "币种",
  133. prop: "currency",
  134. data: accountCurrency.value,
  135. },
  136. ];
  137. });
  138. const config = computed(() => {
  139. return [
  140. {
  141. attrs: {
  142. label: "资金账户",
  143. prop: "accountManagementName",
  144. width: 200,
  145. },
  146. },
  147. {
  148. attrs: {
  149. label: "交易时间",
  150. prop: "transactionTime",
  151. width: 160,
  152. },
  153. },
  154. {
  155. attrs: {
  156. label: "交易金额",
  157. slot: "amount",
  158. width: 200,
  159. },
  160. },
  161. {
  162. attrs: {
  163. label: "对方账户",
  164. prop: "name",
  165. width: 200,
  166. },
  167. },
  168. {
  169. attrs: {
  170. label: "对方银行",
  171. prop: "openingBank",
  172. width: 200,
  173. },
  174. },
  175. {
  176. attrs: {
  177. label: "对方账号",
  178. prop: "accountOpening",
  179. width: 240,
  180. },
  181. },
  182. {
  183. attrs: {
  184. label: "摘要",
  185. prop: "remarks",
  186. },
  187. },
  188. {
  189. attrs: {
  190. label: "操作",
  191. width: "120",
  192. align: "center",
  193. },
  194. renderHTML(row) {
  195. return [
  196. {
  197. attrs: {
  198. label: "修改",
  199. type: "primary",
  200. text: true,
  201. },
  202. el: "button",
  203. click() {
  204. update(row);
  205. },
  206. },
  207. {
  208. attrs: {
  209. label: "删除",
  210. type: "primary",
  211. text: true,
  212. },
  213. el: "button",
  214. click() {
  215. ElMessageBox.confirm("此操作将永久删除该数据, 是否继续?", "提示", {
  216. confirmButtonText: "确定",
  217. cancelButtonText: "取消",
  218. type: "warning",
  219. }).then(() => {
  220. proxy
  221. .post("/accountRunningWater/delete", {
  222. id: row.id,
  223. })
  224. .then(() => {
  225. ElMessage({
  226. message: "删除成功",
  227. type: "success",
  228. });
  229. getList();
  230. });
  231. });
  232. },
  233. },
  234. ];
  235. },
  236. },
  237. ];
  238. });
  239. const getDict = () => {
  240. proxy
  241. .post("/dictTenantData/page", {
  242. pageNum: 1,
  243. pageSize: 999,
  244. dictCode: "account_currency",
  245. tenantId: useUserStore().user.tenantId,
  246. })
  247. .then((res) => {
  248. if (res.rows && res.rows.length > 0) {
  249. accountCurrency.value = res.rows.map((item) => {
  250. return {
  251. label: item.dictValue,
  252. value: item.dictKey,
  253. };
  254. });
  255. }
  256. });
  257. proxy.post("/accountManagement/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  258. if (res.rows && res.rows.length > 0) {
  259. accountList.value = res.rows.map((item) => {
  260. return {
  261. label: item.alias,
  262. value: item.id,
  263. };
  264. });
  265. }
  266. });
  267. };
  268. const getList = async (req) => {
  269. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  270. loading.value = true;
  271. proxy.post("/accountRunningWater/page", sourceList.value.pagination).then((res) => {
  272. sourceList.value.data = res.rows;
  273. sourceList.value.pagination.total = res.total;
  274. setTimeout(() => {
  275. loading.value = false;
  276. }, 200);
  277. });
  278. };
  279. getDict();
  280. getList();
  281. const modalType = ref("add");
  282. const dialogVisible = ref(false);
  283. const loadingDialog = ref(false);
  284. const submit = ref(null);
  285. const formOption = reactive({
  286. inline: true,
  287. labelWidth: 100,
  288. itemWidth: 100,
  289. rules: [],
  290. });
  291. const formData = reactive({
  292. data: {},
  293. });
  294. const formConfig = computed(() => {
  295. return [
  296. {
  297. label: "账户信息",
  298. },
  299. {
  300. type: "select",
  301. prop: "accountManagementId",
  302. label: "选择账户",
  303. data: accountList.value,
  304. },
  305. {
  306. label: "交易信息",
  307. },
  308. {
  309. type: "slot",
  310. prop: "transactionTime",
  311. slotName: "transactionTime",
  312. label: "交易时间",
  313. },
  314. {
  315. type: "slot",
  316. prop: "money",
  317. slotName: "money",
  318. label: "交易金额",
  319. },
  320. formData.data.status == "10"
  321. ? {
  322. type: "slot",
  323. prop: "received",
  324. slotName: "received",
  325. label: "合同到账",
  326. }
  327. : {},
  328. {
  329. label: "对方信息",
  330. },
  331. {
  332. type: "input",
  333. prop: "name",
  334. label: "账户名称",
  335. itemType: "text",
  336. },
  337. {
  338. type: "input",
  339. prop: "openingBank",
  340. label: "开户银行",
  341. itemType: "text",
  342. },
  343. {
  344. type: "input",
  345. prop: "accountOpening",
  346. label: "银行账号",
  347. itemType: "text",
  348. },
  349. {
  350. label: "其他信息",
  351. },
  352. {
  353. type: "input",
  354. prop: "remarks",
  355. label: "摘要",
  356. itemType: "textarea",
  357. },
  358. ];
  359. });
  360. const rules = ref({
  361. accountManagementId: [{ required: true, message: "请选择账户", trigger: "change" }],
  362. transactionTime: [{ required: true, message: "请选择交易时间", trigger: "change" }],
  363. status: [{ required: true, message: "请选择收支类型", trigger: "change" }],
  364. currency: [{ required: true, message: "请选择币种", trigger: "change" }],
  365. received: [{ required: true, message: "请选择合同是否到账", trigger: "change" }],
  366. amount: [{ required: true, message: "请输入金额", trigger: "blur" }],
  367. name: [{ required: true, message: "请输入账户名称", trigger: "blur" }],
  368. openingBank: [{ required: true, message: "请输入开户银行", trigger: "blur" }],
  369. accountOpening: [{ required: true, message: "请输入银行账号", trigger: "blur" }],
  370. });
  371. const openModal = (val) => {
  372. modalType.value = val;
  373. formData.data = {
  374. transactionTime: moment().format("yyyy-MM-DD HH:mm:ss")
  375. };
  376. loadingDialog.value = false;
  377. dialogVisible.value = true;
  378. };
  379. const changeStatus = () => {
  380. formData.data.received = "";
  381. };
  382. const submitForm = () => {
  383. submit.value.handleSubmit(() => {
  384. loadingDialog.value = true;
  385. proxy.post("/accountRunningWater/" + modalType.value, formData.data).then(
  386. () => {
  387. ElMessage({
  388. message: modalType.value == "add" ? "添加成功" : "编辑成功",
  389. type: "success",
  390. });
  391. dialogVisible.value = false;
  392. getList();
  393. },
  394. (err) => {
  395. console.log(err);
  396. loadingDialog.value = false;
  397. }
  398. );
  399. });
  400. };
  401. const update = (row) => {
  402. modalType.value = "edit";
  403. loadingDialog.value = true;
  404. proxy.post("/accountRunningWater/detail", { id: row.id }).then((res) => {
  405. formData.data = res;
  406. loadingDialog.value = false;
  407. });
  408. dialogVisible.value = true;
  409. };
  410. </script>
  411. <style lang="scss" scoped>
  412. .tenant {
  413. padding: 20px;
  414. }
  415. ::v-deep(.el-input-number .el-input__inner) {
  416. text-align: left;
  417. }
  418. </style>