index.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <div class="page-container list-container">
  3. <!-- 功能按钮区 -->
  4. <div class="list-btns-container">
  5. <el-button type="primary" size="small" icon="Plus" @click="handleAdd"
  6. v-hasPermi="['business:account:add']">新增</el-button>
  7. <el-button type="danger" size="small" icon="Delete" :disabled="multiple" @click="handleDelete"
  8. v-hasPermi="['business:account:remove']">删除</el-button>
  9. <el-dropdown>
  10. <el-button type="primary" size="small">
  11. 其它<el-icon class="el-icon--right"><arrow-down /></el-icon>
  12. </el-button>
  13. <template #dropdown>
  14. <el-dropdown-menu>
  15. <el-dropdown-item icon="Download" @click="handleExport" v-hasPermi="['business:account:export']">
  16. 导出</el-dropdown-item>
  17. </el-dropdown-menu>
  18. </template>
  19. </el-dropdown>
  20. </div>
  21. <!-- 搜索区 -->
  22. <el-form class="list-search-container" size="small" :model="queryParams" ref="queryRef" :inline="true"
  23. label-width="68px">
  24. <el-form-item label="账户名称:" prop="name">
  25. <el-input v-model="queryParams.name" placeholder="请输入账户名称" style="width: 150px" clearable
  26. @keyup.enter="handleQuery" />
  27. </el-form-item>
  28. <el-form-item label="账号:" prop="accountNum">
  29. <el-input v-model="queryParams.accountNum" placeholder="请输入账号" style="width: 150px" clearable
  30. @keyup.enter="handleQuery" />
  31. </el-form-item>
  32. <el-form-item label="开户行:" prop="accountOpen">
  33. <el-input v-model="queryParams.accountOpen" placeholder="请输入开户行" style="width: 150px" clearable
  34. @keyup.enter="handleQuery" />
  35. </el-form-item>
  36. <el-form-item>
  37. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  38. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  39. </el-form-item>
  40. </el-form>
  41. <!-- 列表区 -->
  42. <el-table v-loading="loading" :data="accountList" size="small" border height="100%"
  43. @selection-change="handleSelectionChange">
  44. <el-table-column type="selection" width="55" align="center" />
  45. <el-table-column label="账户名称" align="center" prop="name">
  46. <template #default="scope">
  47. <el-input v-if="scope.row.isAdd || scope.row.isEdit" v-model="scope.row.name" size="small"
  48. placeholder="请输入内容"></el-input>
  49. <span v-else>{{ scope.row.name }}</span>
  50. </template>
  51. </el-table-column>
  52. <el-table-column label="账号" align="center" prop="accountNum">
  53. <template #default="scope">
  54. <el-input v-if="scope.row.isAdd || scope.row.isEdit" size="small" v-model="scope.row.accountNum"
  55. placeholder="请输入内容"></el-input>
  56. <span v-else>{{ scope.row.accountNum }}</span>
  57. </template>
  58. </el-table-column>
  59. <el-table-column label="开户行" align="center" prop="accountOpen">
  60. <template #default="scope">
  61. <el-input v-if="scope.row.isAdd || scope.row.isEdit" size="small" v-model="scope.row.accountOpen"
  62. placeholder="请输入内容"></el-input>
  63. <span v-else>{{ scope.row.accountOpen }}</span>
  64. </template>
  65. </el-table-column>
  66. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  67. <template #default="scope">
  68. <el-button v-show="!scope.row.isAdd &&
  69. !scope.row.isEdit &&
  70. scope.row.referrerDataSource == isReferrerDataSource
  71. " link type="warning" size="small" @click="handleUpdate(scope.row)"
  72. v-hasPermi="['business:account:edit']">修改</el-button>
  73. <el-button v-show="!scope.row.isAdd &&
  74. !scope.row.isEdit &&
  75. scope.row.referrerDataSource == isReferrerDataSource
  76. " link type="danger" size="small" @click="handleDelete(scope.row)"
  77. v-hasPermi="['business:account:remove']">删除</el-button>
  78. <el-button v-show="scope.row.isAdd ||
  79. (scope.row.isEdit &&
  80. scope.row.referrerDataSource == isReferrerDataSource)
  81. " link type="primary" size="small" v-hasPermi="['business:account:edit', 'business:account:add']"
  82. @click="handleSave(scope.row)">保存</el-button>
  83. <el-button v-if="scope.row.isEdit || scope.row.isAdd" link size="small"
  84. @click="handCancel(scope.row)">取消</el-button>
  85. </template>
  86. </el-table-column>
  87. </el-table>
  88. <!-- 分页 -->
  89. <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize"
  90. @pagination="getList" />
  91. <!-- 表单 -->
  92. <account-form ref="accountRef" :get-list="getList"></account-form>
  93. </div>
  94. </template>
  95. <script setup name="Account">
  96. import {
  97. listAccount,
  98. delAccount,
  99. addAccount,
  100. updateAccount,
  101. } from "@/api/business/account";
  102. import accountForm from "./form";
  103. const { proxy } = getCurrentInstance();
  104. /** 字典数组区 */
  105. /** 查询 对象 */
  106. const accountList = ref([]);
  107. const loading = ref(true);
  108. const ids = ref([]);
  109. const single = ref(true);
  110. const multiple = ref(true);
  111. const total = ref(0);
  112. /** 查询对象 */
  113. const queryParams = ref({
  114. pageNum: 1,
  115. pageSize: 10,
  116. tenantId: null,
  117. orderByColumn: "create_time",
  118. name: null,
  119. accountNum: null,
  120. accountOpen: null,
  121. createTime: null,
  122. isEdit: false,
  123. isAdd: false,
  124. });
  125. /*********************** 方法区 ****************************/
  126. /** 查询银行账户列表 */
  127. function getList() {
  128. loading.value = true;
  129. listAccount(queryParams.value).then((response) => {
  130. accountList.value = response.rows;
  131. total.value = response.total;
  132. loading.value = false;
  133. });
  134. }
  135. /** 搜索按钮操作 */
  136. function handleQuery() {
  137. queryParams.value.pageNum = 1;
  138. getList();
  139. }
  140. /** 重置按钮操作 */
  141. function resetQuery() {
  142. proxy.resetForm("queryRef");
  143. handleQuery();
  144. }
  145. // 多选框选中数据
  146. function handleSelectionChange(selection) {
  147. ids.value = selection.map((item) => item.id);
  148. single.value = selection.length != 1;
  149. multiple.value = !selection.length;
  150. }
  151. /** 保存按钮操作 */
  152. function handleSave(row) {
  153. if (row.name == null || row.name == "") {
  154. proxy.$modal.msgError("账户名称不能为空!");
  155. return;
  156. }
  157. if (row.accountNum == null || row.accountNum == "") {
  158. proxy.$modal.msgError("账号不能为空!");
  159. return;
  160. }
  161. if (row.accountOpen == null || row.accountOpen == "") {
  162. proxy.$modal.msgError("开户行不能为空!");
  163. return;
  164. }
  165. if (row.isAdd) {
  166. addAccount(row).then((response) => {
  167. proxy.$modal.msgSuccess("添加成功");
  168. visible.value = false;
  169. getList.value();
  170. });
  171. row.isAdd = false;
  172. getList();
  173. getList();
  174. }
  175. if (row.isEdit) {
  176. updateAccount(row).then((response) => {
  177. proxy.$modal.msgSuccess("修改成功");
  178. visible.value = false;
  179. getList.value();
  180. });
  181. queryParams.isEdit = false;
  182. getList();
  183. }
  184. getList();
  185. }
  186. /** 新增按钮操作 */
  187. function handleAdd() {
  188. // 此处必须进行深拷贝,否则添加的明细,将都指向了一个对象
  189. const _newSource = JSON.parse(JSON.stringify(queryParams.value));
  190. accountList.value.push(_newSource);
  191. handleSourceCurrentChange(_newSource);
  192. }
  193. /** 取消按钮操作 */
  194. function handCancel(row) {
  195. if (row.isEdit) row.isEdit = false;
  196. else accountList.value.length = accountList.value.length - 1;
  197. }
  198. /** 修改按钮操作 */
  199. function handleSourceCurrentChange(row) {
  200. row.isAdd = true;
  201. }
  202. /** 修改按钮操作 */
  203. function handleUpdate(row) {
  204. row.isEdit = true;
  205. }
  206. /** 删除按钮操作 */
  207. function handleDelete(row) {
  208. const _ids = row.id || ids.value;
  209. proxy.$modal
  210. .confirm("是否确认删除选中的数据项?")
  211. .then(function () {
  212. return delAccount(_ids);
  213. })
  214. .then(() => {
  215. getList();
  216. proxy.$modal.msgSuccess("删除成功!");
  217. })
  218. .catch(() => { });
  219. }
  220. /** 导出按钮操作 */
  221. function handleExport() {
  222. proxy.download(
  223. "business/account/export",
  224. {
  225. ...queryParams.value,
  226. },
  227. `account_${new Date().getTime()}.xlsx`
  228. );
  229. }
  230. getList();
  231. </script>