index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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. import dictMixins from '@/mixins/dictMixins';
  89. export default {
  90. mixins: [tabMixins, dictMixins],
  91. components: {
  92. searchForm,
  93. addDialog
  94. },
  95. data() {
  96. return {
  97. selection: [],
  98. loading: false,
  99. columns: [
  100. {
  101. width: 45,
  102. type: 'selection',
  103. columnKey: 'selection',
  104. align: 'center'
  105. },
  106. {
  107. columnKey: 'index',
  108. label: '序号',
  109. type: 'index',
  110. width: 55,
  111. align: 'center',
  112. showOverflowTooltip: true,
  113. fixed: 'left'
  114. },
  115. {
  116. prop: 'code',
  117. label: '编码',
  118. align: 'center',
  119. // sortable: true,
  120. showOverflowTooltip: true,
  121. minWidth: 160
  122. },
  123. {
  124. prop: 'name',
  125. label: '收款条件名称',
  126. align: 'center',
  127. showOverflowTooltip: true,
  128. minWidth: 160
  129. },
  130. {
  131. prop: 'dateType',
  132. label: '收款日计算日期',
  133. align: 'center',
  134. showOverflowTooltip: true,
  135. minWidth: 160,
  136. formatter: (row) => {
  137. return calcReceiveDateTypeOp.find(item => item.value === row.dateType)?.label || '';
  138. }
  139. },
  140. {
  141. prop: 'rulesTypePOList',
  142. label: '支付方式',
  143. align: 'center',
  144. showOverflowTooltip: true,
  145. minWidth: 140,
  146. formatter: (row) => {
  147. return this.buildPaymentMethod(row.rulesTypePOList);
  148. }
  149. },
  150. {
  151. prop: 'determinationMethod',
  152. label: '收款日确认方式',
  153. align: 'center',
  154. showOverflowTooltip: true,
  155. minWidth: 140,
  156. formatter: (row) => {
  157. return payConfirmTypeOp.find(item => item.value === row.determinationMethod)?.label || '';
  158. }
  159. },
  160. {
  161. prop: 'remark',
  162. label: '备注',
  163. align: 'center',
  164. showOverflowTooltip: true,
  165. minWidth: 180
  166. },
  167. {
  168. prop: 'createUserName',
  169. label: '创建人',
  170. align: 'center',
  171. showOverflowTooltip: true,
  172. minWidth: 120
  173. },
  174. {
  175. prop: 'createTime',
  176. label: '创建时间',
  177. align: 'center',
  178. showOverflowTooltip: true,
  179. minWidth: 120
  180. },
  181. {
  182. prop: 'ruleState',
  183. slot: 'ruleState',
  184. label: '状态',
  185. align: 'center',
  186. showOverflowTooltip: true,
  187. minWidth: 120
  188. },
  189. {
  190. columnKey: 'action',
  191. label: '操作',
  192. width: 170,
  193. align: 'center',
  194. resizable: false,
  195. slot: 'action',
  196. showOverflowTooltip: true,
  197. fixed: 'right'
  198. }
  199. ],
  200. cacheKeyUrl: 'eos-receiveTerms-list'
  201. };
  202. },
  203. created() {
  204. this.requestDict('支付类型');
  205. },
  206. methods: {
  207. /* 表格数据源 */
  208. async datasource({ page, limit, where, order }) {
  209. const res = await getTableList({
  210. pageNum: page,
  211. size: limit,
  212. conditionConfigurationType: 'rules',
  213. ...where
  214. });
  215. console.log('res', res);
  216. return res
  217. },
  218. /* 刷新表格 */
  219. reload(where) {
  220. this.$refs.table.reload({ page: 1, where });
  221. },
  222. // 新增编辑
  223. openEdit(type, row) {
  224. this.$refs.addDialogRef.open(type, row);
  225. },
  226. // 查看详情
  227. openDetail(row) {
  228. this.$refs.addDialogRef.open('detail', row);
  229. },
  230. // 删除
  231. remove(delData) {
  232. deleteInformation(delData).then(() => {
  233. this.$message.success('删除成功!');
  234. this.reload();
  235. });
  236. },
  237. // 构建支付方式字符串
  238. buildPaymentMethod(list) {
  239. return list
  240. .map(item => {
  241. const unit =
  242. (dateUnitOptions.find(opt => opt.value === item.dateType) || {}).label ||
  243. '月';
  244. return `${item.percentage}% ${item.paymentSum}${unit} ${this.dict['payment_type'].find(opt => opt.dictCode === item.paymentType)?.dictValue || ''}`;
  245. })
  246. .join(',');
  247. },
  248. handleStatus(row, val) {
  249. console.log('row', row);
  250. console.log('val', val);
  251. let msg = val == 1 ? '是否启用该规则' : '是否关闭该规则';
  252. this.$confirm(msg, '提示', {
  253. type: 'warning'
  254. })
  255. .then(async () => {
  256. await updateRuleState({
  257. id: row.id,
  258. ruleState: val
  259. });
  260. this.$message.success('操作成功');
  261. })
  262. .catch(() => {
  263. row.ruleState = val == 1 ? 0 : 1;
  264. });
  265. }
  266. }
  267. };
  268. </script>
  269. <style lang="scss" scoped>
  270. :deep(.el-link--inner) {
  271. margin-left: 0px !important;
  272. }
  273. </style>