AccountList.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <!-- f r o m 7 5 2 7 1 8 9 2 0 -->
  2. <template>
  3. <a-row :gutter="24">
  4. <a-col :md="24">
  5. <a-card :style="cardStyle" :bordered="false">
  6. <!-- 查询区域 -->
  7. <div class="table-page-search-wrapper">
  8. <!-- 搜索区域 -->
  9. <a-form layout="inline" @keyup.enter.native="searchQuery">
  10. <a-row :gutter="24">
  11. <a-col :md="6" :sm="24">
  12. <a-form-item label="名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
  13. <a-input placeholder="请输入名称查询" v-model="queryParam.name"></a-input>
  14. </a-form-item>
  15. </a-col>
  16. <a-col :md="6" :sm="24">
  17. <a-form-item label="编号" :labelCol="labelCol" :wrapperCol="wrapperCol">
  18. <a-input placeholder="请输入编号查询" v-model="queryParam.serialNo"></a-input>
  19. </a-form-item>
  20. </a-col>
  21. <a-col :md="6" :sm="24">
  22. <a-form-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol">
  23. <a-input placeholder="请输入备注查询" v-model="queryParam.remark"></a-input>
  24. </a-form-item>
  25. </a-col>
  26. <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
  27. <a-col :md="6" :sm="24">
  28. <a-button type="primary" @click="searchQuery">查询</a-button>
  29. <a-button style="margin-left: 8px" @click="searchReset">重置</a-button>
  30. </a-col>
  31. </span>
  32. </a-row>
  33. </a-form>
  34. </div>
  35. <!-- 操作按钮区域 -->
  36. <div class="table-operator" style="margin-top: 5px">
  37. <a-button v-if="btnEnableList.indexOf(1) > -1" @click="handleAdd" type="primary" icon="plus">新增</a-button>
  38. <a-button v-if="btnEnableList.indexOf(1) > -1" @click="batchDel" icon="delete">删除</a-button>
  39. <a-button v-if="btnEnableList.indexOf(1) > -1" @click="batchSetStatus(true)" icon="check-square"
  40. >启用</a-button
  41. >
  42. <a-button v-if="btnEnableList.indexOf(1) > -1" @click="batchSetStatus(false)" icon="close-square"
  43. >禁用</a-button
  44. >
  45. </div>
  46. <!-- table区域-begin -->
  47. <div>
  48. <a-table
  49. ref="table"
  50. size="middle"
  51. bordered
  52. rowKey="id"
  53. :columns="columns"
  54. :dataSource="dataSource"
  55. :pagination="ipagination"
  56. :scroll="scroll"
  57. :loading="loading"
  58. :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
  59. @change="handleTableChange"
  60. >
  61. <span slot="action" slot-scope="text, record">
  62. <a-popconfirm
  63. v-if="btnEnableList.indexOf(1) > -1"
  64. title="确定设为默认吗?"
  65. @confirm="() => handleSetDefault(record.id)"
  66. >
  67. <a>设为默认</a>
  68. </a-popconfirm>
  69. <a-divider v-if="btnEnableList.indexOf(1) > -1" type="vertical" />
  70. <a @click="handleEdit(record)">编辑</a>
  71. <a-divider v-if="btnEnableList.indexOf(1) > -1" type="vertical" />
  72. <a-popconfirm
  73. v-if="btnEnableList.indexOf(1) > -1"
  74. title="确定删除吗?"
  75. @confirm="() => handleDelete(record.id)"
  76. >
  77. <a>删除</a>
  78. </a-popconfirm>
  79. </span>
  80. <!-- 状态渲染模板 -->
  81. <template slot="customRenderEnabledFlag" slot-scope="enabled">
  82. <a-tag v-if="enabled" color="green">启用</a-tag>
  83. <a-tag v-if="!enabled" color="orange">禁用</a-tag>
  84. </template>
  85. <template slot="customRenderFlag" slot-scope="isDefault">
  86. <a-tag v-if="isDefault" color="green">是</a-tag>
  87. <a-tag v-if="!isDefault" color="orange">否</a-tag>
  88. </template>
  89. </a-table>
  90. </div>
  91. <!-- table区域-end -->
  92. <!-- 表单区域 -->
  93. <account-modal ref="modalForm" @ok="modalFormOk"></account-modal>
  94. </a-card>
  95. </a-col>
  96. </a-row>
  97. </template>
  98. <!-- BY cao_yu_li -->
  99. <script>
  100. import AccountModal from './modules/AccountModal'
  101. import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  102. import JDate from '@/components/jeecg/JDate'
  103. import { postAction } from '@api/manage'
  104. export default {
  105. name: 'AccountList',
  106. mixins: [JeecgListMixin],
  107. components: {
  108. AccountModal,
  109. JDate,
  110. },
  111. data() {
  112. return {
  113. labelCol: {
  114. span: 5,
  115. },
  116. wrapperCol: {
  117. span: 18,
  118. offset: 1,
  119. },
  120. // 查询条件
  121. queryParam: { name: '', serialNo: '', remark: '' },
  122. // 表头
  123. columns: [
  124. {
  125. title: '#',
  126. dataIndex: '',
  127. key: 'rowIndex',
  128. width: 40,
  129. align: 'center',
  130. customRender: function (t, r, index) {
  131. return parseInt(index) + 1
  132. },
  133. },
  134. {
  135. title: '操作',
  136. dataIndex: 'action',
  137. width: 150,
  138. align: 'center',
  139. scopedSlots: { customRender: 'action' },
  140. },
  141. { title: '名称', dataIndex: 'name', width: 100, align: 'left' },
  142. { title: '编号', dataIndex: 'serialNo', width: 150, align: 'left' },
  143. { title: '期初金额', dataIndex: 'initialAmount', width: 100, align: 'left' },
  144. { title: '备注', dataIndex: 'remark', width: 200, align: 'left' },
  145. { title: '排序', dataIndex: 'sort', width: 60, align: 'left' },
  146. {
  147. title: '状态',
  148. dataIndex: 'enabled',
  149. width: 60,
  150. align: 'center',
  151. scopedSlots: { customRender: 'customRenderEnabledFlag' },
  152. },
  153. {
  154. title: '是否默认',
  155. dataIndex: 'isDefault',
  156. width: 80,
  157. align: 'center',
  158. scopedSlots: { customRender: 'customRenderFlag' },
  159. },
  160. ],
  161. url: {
  162. list: '/account/list',
  163. delete: '/account/delete',
  164. deleteBatch: '/account/deleteBatch',
  165. setDefault: '/account/updateIsDefault',
  166. batchSetStatusUrl: '/account/batchSetStatus',
  167. },
  168. }
  169. },
  170. computed: {},
  171. methods: {
  172. handleSetDefault: function (id) {
  173. if (!this.url.setDefault) {
  174. this.$message.error('请设置url.delete属性!')
  175. return
  176. }
  177. let that = this
  178. postAction(that.url.setDefault, { id: id }).then((res) => {
  179. if (res.code === 200) {
  180. that.loadData()
  181. } else {
  182. that.$message.warning(res.data.message)
  183. }
  184. })
  185. },
  186. handleEdit: function (record) {
  187. this.$refs.modalForm.edit(record)
  188. this.$refs.modalForm.title = '编辑'
  189. this.$refs.modalForm.disableSubmit = false
  190. if (this.btnEnableList.indexOf(1) === -1) {
  191. this.$refs.modalForm.isReadOnly = true
  192. }
  193. },
  194. },
  195. }
  196. </script>
  197. <style scoped>
  198. @import '~@assets/less/common.less';
  199. </style>