indexClassifyDict.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <template>
  2. <a-card :bordered="false">
  3. <div class="table-page-search-wrapper" v-if="hasPerm('classifyDistIndex:page')">
  4. <a-form layout="inline">
  5. <a-row :gutter="48">
  6. <a-col :md="16" :sm="20">
  7. <a-radio-group default-value="1" v-model="queryParam.systemDictType" button-style="solid" @change="$refs.table.refresh(true)">
  8. <a-radio-button v-for="(item,index) in typeList" :key="index" :value="item.code">
  9. {{ item.name }}
  10. </a-radio-button>
  11. </a-radio-group>
  12. </a-col>
  13. <a-col :md="8" :sm="4">
  14. <a-button type="primary" style="margin-left: 8px" v-if="hasPerm('classifyDistIndex:add')" icon="plus" @click="$refs.addForm.add({'systemDictType': queryParam.systemDictType})">新增</a-button>
  15. </a-col>
  16. </a-row>
  17. </a-form>
  18. </div>
  19. <s-table
  20. ref="table"
  21. size="default"
  22. :columns="columns"
  23. :data="loadData"
  24. :alert="true"
  25. :rowKey="(record) => record.systemDictId"
  26. >
  27. <span slot="systemDictType" slot-scope="text">
  28. {{ typeFilter(text) }}
  29. </span>
  30. <span slot="action" slot-scope="text, record">
  31. <a-popconfirm placement="top" :title="record.systemDictIsLine===1? '是否确认下线该条目?':'是否确认上线该条目?'" @confirm="() => editjobStatusStatus(record.systemDictIsLine,record)">
  32. <a>{{ statusFilter(record.systemDictIsLine) }}</a>
  33. </a-popconfirm>
  34. <a-divider type="vertical"/>
  35. <a v-if="hasPerm('classifyDistIndex:edit')" @click="$refs.editForm.edit(record)">编辑</a>
  36. <a-divider type="vertical" v-if="hasPerm('classifyDistIndex:edit') && hasPerm('classifyDistIndex:delete')"/>
  37. <a-popconfirm v-if="hasPerm('classifyDistIndex:delete')" placement="topRight" title="是否确认删除该条目?" @confirm="() => classifyDistIndexDelete(record)">
  38. <a>删除</a>
  39. </a-popconfirm>
  40. </span>
  41. </s-table>
  42. <add-form ref="addForm" @ok="handleOk" />
  43. <edit-form ref="editForm" @ok="handleOk" />
  44. </a-card>
  45. </template>
  46. <script>
  47. import { STable, Ellipsis } from '@/components'
  48. import homeApi from '@/api/homeApi'
  49. import addForm from './addClassifyDictForm'
  50. import editForm from './editClassifyDictForm'
  51. export default {
  52. name: 'ClassifyDistIndex',
  53. components: {
  54. STable,
  55. Ellipsis,
  56. addForm,
  57. editForm
  58. },
  59. data () {
  60. return {
  61. typeList: homeApi.systemTypeList,
  62. // 查询参数
  63. queryParam: { id: '', systemDictType: 1 },
  64. // 表头
  65. columns: [
  66. {
  67. title: '序号',
  68. dataIndex: 'dataIndex',
  69. customRender: (text, row, index) => {
  70. return index + 1
  71. },
  72. align: 'center',
  73. width: '90px'
  74. },
  75. {
  76. title: '所属类别',
  77. dataIndex: 'systemDictType',
  78. scopedSlots: { customRender: 'systemDictType' }
  79. },
  80. {
  81. title: '分类',
  82. dataIndex: 'systemDictClassify',
  83. scopedSlots: { customRender: 'systemDictClassify' }
  84. },
  85. {
  86. title: '子分类',
  87. dataIndex: 'systemDictSubclassify',
  88. scopedSlots: { customRender: 'systemDictSubclassify' }
  89. },
  90. {
  91. title: '排序',
  92. dataIndex: 'systemDictSort',
  93. align: 'center'
  94. }
  95. ],
  96. // 加载数据方法 必须为 Promise 对象
  97. loadData: parameter => {
  98. return homeApi.findSystemDictById(Object.assign(parameter, this.queryParam)).then((res) => {
  99. return res.data
  100. })
  101. },
  102. selectedRowKeys: [],
  103. selectedRows: [],
  104. statusDictTypeDropDown: [{ code: 0, name: '下线' }, { code: 1, name: '上线' }]
  105. }
  106. },
  107. created () {
  108. if (this.hasPerm('classifyDistIndex:edit') || this.hasPerm('classifyDistIndex:delete') || hasPerm('classifyDistIndex:start') || hasPerm('classifyDistIndex:stop')) {
  109. this.columns.push({
  110. title: '操作',
  111. dataIndex: 'action',
  112. align: 'center',
  113. scopedSlots: { customRender: 'action' }
  114. })
  115. }
  116. },
  117. methods: {
  118. statusFilter (status) {
  119. const values = this.statusDictTypeDropDown.filter(item => item.code === status)
  120. if (values.length > 0) {
  121. return values[0].name
  122. } else {
  123. return '上线'
  124. }
  125. },
  126. typeFilter (status) {
  127. const values = this.typeList.filter(item => item.code === status)
  128. if (values.length > 0) {
  129. return values[0].name
  130. } else {
  131. return ''
  132. }
  133. },
  134. /**
  135. * 启动停止
  136. */
  137. editjobStatusStatus (code, record) {
  138. if (code === 1) {
  139. homeApi.updateIsLineSystemDict({ id: record.systemDictId, isLine: 0 }).then(res => {
  140. if (res.status === 200) {
  141. if (res.data) {
  142. this.$message.success('下线成功')
  143. this.$refs.table.refresh()
  144. } else {
  145. this.$message.error('下线失败')
  146. }
  147. } else {
  148. this.$message.error('下线失败:' + res.msg)
  149. }
  150. })
  151. } else {
  152. homeApi.updateIsLineSystemDict({ id: record.systemDictId, isLine: 1 }).then(res => {
  153. if (res.status === 200) {
  154. if (res.data) {
  155. this.$message.success('上线成功')
  156. this.$refs.table.refresh()
  157. } else {
  158. this.$message.error('上线失败')
  159. }
  160. } else {
  161. this.$message.error('上线失败:' + res.msg)
  162. }
  163. })
  164. }
  165. },
  166. classifyDistIndexDelete (record) {
  167. homeApi.deleteSystemDict({ id: record.systemDictId }).then((res) => {
  168. if (res.status === 200) {
  169. if (res.data) {
  170. this.$message.success('删除成功')
  171. this.$refs.table.refresh()
  172. } else {
  173. this.$message.error('删除失败')
  174. }
  175. } else {
  176. this.$message.error('删除失败:' + res.msg)
  177. }
  178. }).catch((err) => {
  179. this.$message.error('删除错误:' + err.message)
  180. })
  181. },
  182. toggleAdvanced () {
  183. this.advanced = !this.advanced
  184. },
  185. handleOk () {
  186. this.$refs.table.refresh()
  187. },
  188. onSelectChange (selectedRowKeys, selectedRows) {
  189. this.selectedRowKeys = selectedRowKeys
  190. this.selectedRows = selectedRows
  191. }
  192. }
  193. }
  194. </script>
  195. <style lang="less">
  196. .table-operator {
  197. margin-bottom: 18px;
  198. }
  199. button {
  200. margin-right: 8px;
  201. }
  202. </style>