index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <template-page
  3. ref="pageRef"
  4. :getList="getList"
  5. :exportList="exportList"
  6. :columnParsing="columnParsing"
  7. :optionsEvensGroup="optionsEvensGroup"
  8. :morePlan="morePlan"
  9. :operationColumnWidth="200"
  10. :operation="operation()"
  11. >
  12. <Popu v-if="visible">
  13. <el-page-header slot="head" content="" @back="handleClose" />
  14. <InsuranceContractForm
  15. :item="item"
  16. :type="showType"
  17. @success="
  18. () => {
  19. handleClose()
  20. $refs.pageRef.refreshList()
  21. }
  22. "
  23. />
  24. </Popu>
  25. </template-page>
  26. </template>
  27. <script>
  28. import TemplatePage from '@/components/template/template-page-1.vue'
  29. import import_mixin from '@/components/template/import_mixin.js'
  30. import add_callback_mixin from '@/components/template/add_callback_mixin.js'
  31. import Popu from '@/components/template/popu.vue'
  32. import InsuranceContractForm from './InsuranceContractForm.vue'
  33. import operation_mixin from '@/components/template/operation_mixin.js'
  34. import { insureList, insureListExport, insureOnOff, insureDelete } from '@/api/InsuranceManagement.js'
  35. export default {
  36. components: { TemplatePage, Popu, InsuranceContractForm },
  37. mixins: [import_mixin, add_callback_mixin, operation_mixin],
  38. data() {
  39. return {
  40. morePlan: [],
  41. // 事件组合
  42. optionsEvensGroup: [
  43. [
  44. [
  45. {
  46. name: '新增',
  47. isRole: this.$restrict('add'),
  48. click: this.addOn(() => {
  49. this.item = null
  50. this.showType = 0
  51. this.visible = true
  52. })
  53. }
  54. ]
  55. ]
  56. ],
  57. // 关闭新增弹窗
  58. handleClose: this.addOff(() => {
  59. this.visible = false
  60. this.item = null
  61. this.showType = null
  62. }),
  63. // 表格属性
  64. tableAttributes: {
  65. // 启用勾选列
  66. selectColumn: true
  67. },
  68. // 表格事件
  69. tableEvents: {
  70. 'selection-change': this.selectionChange
  71. },
  72. recordSelected: [],
  73. visible: false,
  74. item: null,
  75. showType: null
  76. }
  77. },
  78. methods: {
  79. // 列表请求函数
  80. getList: insureList,
  81. // 导出
  82. exportList: insureListExport,
  83. // 表格列解析渲染数据更改
  84. columnParsing(item, defaultData) {
  85. if (item.jname === 'status') {
  86. defaultData.render = (h, { row, index, column }) => {
  87. return (
  88. <div class="operation-btns">
  89. <el-switch
  90. value={row.status}
  91. onInput={value => (row.status = value)}
  92. active-value="有效"
  93. inactive-value="无效"
  94. onChange={() => {
  95. insureOnOff({
  96. id: row.id,
  97. status: row.status === '有效' ? 'ON' : 'OFF'
  98. }).then(res => {
  99. this.$successMsg('状态更改成功')
  100. })
  101. }}
  102. ></el-switch>
  103. <span style="margin-left:10px">{row.status}</span>
  104. </div>
  105. )
  106. }
  107. }
  108. return defaultData
  109. },
  110. // 监听勾选变化
  111. selectionChange(data) {
  112. this.recordSelected = data
  113. },
  114. operation() {
  115. return this.operationBtn({
  116. edit: {
  117. conditions: ({ row, index, column }) => {
  118. return true
  119. },
  120. click: ({ row, index, column }) => {
  121. this.item = row
  122. this.visible = true
  123. this.showType = 1
  124. }
  125. },
  126. detail: {
  127. conditions: ({ row, index, column }) => {
  128. return true
  129. },
  130. click: ({ row, index, column }) => {
  131. this.item = row
  132. this.visible = true
  133. this.showType = 2
  134. }
  135. },
  136. del: {
  137. conditions: ({ row, index, column }) => {
  138. return true
  139. },
  140. prompt: '确定删除?',
  141. click: ({ row, index, column }) => {
  142. insureDelete({
  143. id: row.id
  144. })
  145. .then(res => {
  146. this.$refs.pageRef.refreshList()
  147. this.$message({
  148. type: 'success',
  149. message: `删除成功!`
  150. })
  151. })
  152. .catch(err => {
  153. console.log(err)
  154. })
  155. }
  156. }
  157. })
  158. }
  159. }
  160. }
  161. </script>
  162. <style lang="scss" scoped></style>