index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never" v-loading="loading">
  4. <div class="ele-border-lighter form-content" v-loading="loading">
  5. <search-form @search="reload"> </search-form>
  6. <!-- 数据表格 -->
  7. <ele-pro-table
  8. ref="table"
  9. :columns="columns"
  10. :datasource="datasource"
  11. height="calc(100vh - 375px)"
  12. full-height="calc(100vh - 116px)"
  13. tool-class="ele-toolbar-form"
  14. :selection.sync="selection"
  15. :page-size="20"
  16. @columns-change="handleColumnChange"
  17. :cache-key="cacheKeyUrl"
  18. >
  19. <!-- 表头工具栏 -->
  20. <template v-slot:toolbar>
  21. <el-button
  22. size="small"
  23. type="primary"
  24. icon="el-icon-plus"
  25. class="ele-btn-icon"
  26. @click="openEdit('add', {})"
  27. >
  28. 新增
  29. </el-button>
  30. </template>
  31. <template v-slot:ruleState="{ row }">
  32. <el-switch
  33. v-model="row.ruleState"
  34. active-color="#13ce66"
  35. inactive-color="#ff4949"
  36. active-value="1"
  37. inactive-value="0"
  38. @change="(val) => handleStatus(row, val)"
  39. >
  40. </el-switch>
  41. </template>
  42. <!-- 操作列 -->
  43. <template v-slot:action="{ row }">
  44. <el-link
  45. type="primary"
  46. :underline="false"
  47. icon="el-icon-view"
  48. @click="openDetail(row)"
  49. >
  50. 详情
  51. </el-link>
  52. <el-link
  53. type="primary"
  54. :underline="false"
  55. icon="el-icon-edit"
  56. @click="openEdit('edit', row)"
  57. >
  58. 修改
  59. </el-link>
  60. <el-popconfirm
  61. class="ele-action"
  62. title="确定要删除此信息吗?"
  63. @confirm="remove([row.id])"
  64. >
  65. <template v-slot:reference>
  66. <el-link type="danger" :underline="false" icon="el-icon-delete">
  67. 删除
  68. </el-link>
  69. </template>
  70. </el-popconfirm>
  71. </template>
  72. </ele-pro-table>
  73. </div>
  74. </el-card>
  75. <add-dialog ref="addDialogRef" conditionType="rules" @done="reload"></add-dialog>
  76. </div>
  77. </template>
  78. <script>
  79. import searchForm from './components/searchForm.vue';
  80. import addDialog from './components/addDialog.vue';
  81. import tabMixins from '@/mixins/tableColumnsMixin';
  82. import {
  83. getTableList,
  84. deleteInformation,
  85. updateRuleState
  86. } from '@/api/rulesManagement/receiveTerms';
  87. import { calcReceiveDateTypeOp, payConfirmTypeOp, dateUnitOptions } from '@/enum/dict';
  88. export default {
  89. mixins: [tabMixins],
  90. components: {
  91. searchForm,
  92. addDialog
  93. },
  94. data() {
  95. return {
  96. selection: [],
  97. loading: false,
  98. columns: [
  99. {
  100. width: 45,
  101. type: 'selection',
  102. columnKey: 'selection',
  103. align: 'center'
  104. },
  105. {
  106. columnKey: 'index',
  107. label: '序号',
  108. type: 'index',
  109. width: 55,
  110. align: 'center',
  111. showOverflowTooltip: true,
  112. fixed: 'left'
  113. },
  114. {
  115. prop: 'code',
  116. label: '编码',
  117. align: 'center',
  118. // sortable: true,
  119. showOverflowTooltip: true,
  120. minWidth: 160
  121. },
  122. {
  123. prop: 'name',
  124. label: '收款条件名称',
  125. align: 'center',
  126. showOverflowTooltip: true,
  127. minWidth: 160
  128. },
  129. {
  130. prop: 'dateType',
  131. label: '收款日计算日期',
  132. align: 'center',
  133. showOverflowTooltip: true,
  134. minWidth: 160,
  135. formatter: (row) => {
  136. return calcReceiveDateTypeOp.find(item => item.value === row.dateType)?.label || '';
  137. }
  138. },
  139. {
  140. prop: 'rulesTypePOList',
  141. label: '支付方式',
  142. align: 'center',
  143. showOverflowTooltip: true,
  144. minWidth: 140,
  145. formatter: (row) => {
  146. return this.buildPaymentMethod(row.rulesTypePOList);
  147. }
  148. },
  149. {
  150. prop: 'determinationMethod',
  151. label: '收款日确认方式',
  152. align: 'center',
  153. showOverflowTooltip: true,
  154. minWidth: 140,
  155. formatter: (row) => {
  156. return payConfirmTypeOp.find(item => item.value === row.determinationMethod)?.label || '';
  157. }
  158. },
  159. {
  160. prop: 'remark',
  161. label: '备注',
  162. align: 'center',
  163. showOverflowTooltip: true,
  164. minWidth: 180
  165. },
  166. {
  167. prop: 'createUserName',
  168. label: '创建人',
  169. align: 'center',
  170. showOverflowTooltip: true,
  171. minWidth: 120
  172. },
  173. {
  174. prop: 'createTime',
  175. label: '创建时间',
  176. align: 'center',
  177. showOverflowTooltip: true,
  178. minWidth: 120
  179. },
  180. {
  181. prop: 'ruleState',
  182. slot: 'ruleState',
  183. label: '状态',
  184. align: 'center',
  185. showOverflowTooltip: true,
  186. minWidth: 120
  187. },
  188. {
  189. columnKey: 'action',
  190. label: '操作',
  191. width: 170,
  192. align: 'center',
  193. resizable: false,
  194. slot: 'action',
  195. showOverflowTooltip: true,
  196. fixed: 'right'
  197. }
  198. ],
  199. cacheKeyUrl: 'eos-receiveTerms-list'
  200. };
  201. },
  202. methods: {
  203. /* 表格数据源 */
  204. async datasource({ page, limit, where, order }) {
  205. const res = await getTableList({
  206. pageNum: page,
  207. size: limit,
  208. conditionConfigurationType: 'rules',
  209. ...where
  210. });
  211. console.log('res', res);
  212. return res
  213. },
  214. /* 刷新表格 */
  215. reload(where) {
  216. this.$refs.table.reload({ page: 1, where });
  217. },
  218. // 新增编辑
  219. openEdit(type, row) {
  220. this.$refs.addDialogRef.open(type, row);
  221. },
  222. // 查看详情
  223. openDetail(row) {
  224. this.$refs.addDialogRef.open('detail', row);
  225. },
  226. // 删除
  227. remove(delData) {
  228. deleteInformation(delData).then(() => {
  229. this.$message.success('删除成功!');
  230. this.reload();
  231. });
  232. },
  233. // 构建支付方式字符串
  234. buildPaymentMethod(list) {
  235. return list
  236. .map(item => {
  237. const unit =
  238. (dateUnitOptions.find(opt => opt.value === item.dateType) || {}).label ||
  239. '月';
  240. return `${item.percentage}% ${item.paymentSum}${unit} ${item.paymentType}`;
  241. })
  242. .join(',');
  243. },
  244. handleStatus(row, val) {
  245. console.log('row', row);
  246. console.log('val', val);
  247. let msg = val == 1 ? '是否启用该规则' : '是否关闭该规则';
  248. this.$confirm(msg, '提示', {
  249. type: 'warning'
  250. })
  251. .then(async () => {
  252. await updateRuleState({
  253. id: row.id,
  254. ruleState: val
  255. });
  256. this.$message.success('操作成功');
  257. })
  258. .catch(() => {
  259. row.ruleState = val == 1 ? 0 : 1;
  260. });
  261. }
  262. }
  263. };
  264. </script>
  265. <style lang="scss" scoped>
  266. :deep(.el-link--inner) {
  267. margin-left: 0px !important;
  268. }
  269. </style>