list.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <a-card size="small" :bordered="false" class="bindList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  7. <a-row :gutter="15">
  8. <a-col :md="6" :sm="24">
  9. <a-form-item label="中心店名称">
  10. <a-input id="bindList-orgName" v-model.trim="queryParam.orgName" allowClear placeholder="请输入中心店名称"/>
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="配送店名称">
  15. <a-input id="bindList-childName" v-model.trim="queryParam.childName" allowClear placeholder="请输入配送店名称"/>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="bindList-refresh">查询</a-button>
  20. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="bindList-reset">重置</a-button>
  21. </a-col>
  22. </a-row>
  23. </a-form>
  24. </div>
  25. <!-- 操作按钮 -->
  26. <div class="table-operator">
  27. <a-button v-if="$hasPermissions('B_storeManagementBind_add')" id="bindList-add" type="primary" class="button-error" @click="handleEdit()">新增</a-button>
  28. </div>
  29. <!-- 列表 -->
  30. <s-table
  31. class="sTable fixPagination"
  32. ref="table"
  33. :style="{ height: tableHeight+84.5+'px' }"
  34. size="small"
  35. :rowKey="(record) => record.orgSn"
  36. :columns="columns"
  37. :data="loadData"
  38. :scroll="{ y: tableHeight }"
  39. bordered>
  40. <!-- 操作 -->
  41. <template slot="action" slot-scope="text, record">
  42. <a-button
  43. size="small"
  44. type="link"
  45. class="button-info"
  46. @click="handleEdit(record)"
  47. v-if="$hasPermissions('B_storeManagementBind_edit')"
  48. id="bindList-edit-btn">编辑</a-button>
  49. <a-button
  50. size="small"
  51. type="link"
  52. class="button-error"
  53. @click="handleDel(record)"
  54. v-if="$hasPermissions('B_storeManagementBind_del')"
  55. id="bindList-del-btn">删除</a-button>
  56. <span v-if="!$hasPermissions('B_storeManagementBind_edit') &&!$hasPermissions('B_storeManagementBind_del')">--</span>
  57. </template>
  58. </s-table>
  59. </a-spin>
  60. <!-- 新增/编辑 -->
  61. <storeManagement-bind-edit-modal :openModal="openModal" :nowData="nowData" :itemSn="itemSn" @ok="$refs.table.refresh(true)" @close="closeModal" />
  62. </a-card>
  63. </template>
  64. <script>
  65. import { STable } from '@/components'
  66. import storeManagementBindEditModal from './editModal.vue'
  67. import { jxsorgRelationList, jxsorgRelationDel } from '@/api/jxsorg'
  68. export default {
  69. components: { STable, storeManagementBindEditModal },
  70. data () {
  71. return {
  72. spinning: false,
  73. queryParam: { // 查询条件
  74. orgName: '',
  75. childName: ''
  76. },
  77. tableHeight: 0,
  78. disabled: false, // 查询、重置按钮是否可操作
  79. columns: [
  80. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  81. { title: '中心店名称', dataIndex: 'orgName', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  82. { title: '已绑配送店', dataIndex: 'allChildName', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  83. { title: '操作', scopedSlots: { customRender: 'action' }, align: 'center' }
  84. ],
  85. // 加载数据方法 必须为 Promise 对象
  86. loadData: parameter => {
  87. this.disabled = true
  88. return jxsorgRelationList(Object.assign(parameter, this.queryParam)).then(res => {
  89. const data = res.data
  90. const no = (data.pageNo - 1) * data.pageSize
  91. for (var i = 0; i < data.list.length; i++) {
  92. data.list[i].no = no + i + 1
  93. }
  94. this.disabled = false
  95. return data
  96. })
  97. },
  98. openModal: false, // 新增编辑 弹框
  99. itemSn: '', // 当前sn
  100. nowData: null // 当前记录数据
  101. }
  102. },
  103. methods: {
  104. // 重置
  105. resetSearchForm () {
  106. this.queryParam.orgName = ''
  107. this.queryParam.childName = ''
  108. this.$refs.table.refresh(true)
  109. },
  110. // 新增/编辑
  111. handleEdit (row) {
  112. this.itemSn = row ? row.orgSn : null
  113. this.nowData = row || null
  114. this.openModal = true
  115. },
  116. // 关闭弹框
  117. closeModal () {
  118. this.itemSn = ''
  119. this.openModal = false
  120. },
  121. // 删除
  122. handleDel (row) {
  123. const _this = this
  124. this.$confirm({
  125. title: '提示',
  126. content: '删除后会直接解除原有的绑定关系及用户授权,确定删除吗?',
  127. centered: true,
  128. onOk () {
  129. _this.spinning = true
  130. jxsorgRelationDel({
  131. sn: row.orgSn
  132. }).then(res => {
  133. if (res.status == 200) {
  134. _this.$message.success(res.message)
  135. _this.$refs.table.refresh()
  136. _this.spinning = false
  137. } else {
  138. _this.spinning = false
  139. }
  140. })
  141. }
  142. })
  143. },
  144. setTableH () {
  145. const tableSearchH = this.$refs.tableSearch.offsetHeight
  146. this.tableHeight = window.innerHeight - tableSearchH - 235
  147. }
  148. },
  149. activated () {
  150. // 如果是新页签打开,则重置当前页面
  151. if (this.$store.state.app.isNewTab) {
  152. this.resetSearchForm()
  153. }
  154. },
  155. mounted () {
  156. const _this = this
  157. this.$nextTick(() => { // 页面渲染完成后的回调
  158. _this.setTableH()
  159. })
  160. }
  161. }
  162. </script>