list.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <a-card size="small" :bordered="false" class="supplierInfoList-wrap">
  3. <!-- 搜索条件 -->
  4. <div ref="tableSearch" class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  6. <a-row :gutter="15">
  7. <a-col :md="6" :sm="24">
  8. <a-form-item label="供应商名称">
  9. <a-input id="supplierInfoList-supplierName" v-model.trim="queryParam.supplierName" allowClear placeholder="请输入供应商名称"/>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="24">
  13. <a-form-item label="启用状态">
  14. <v-select code="ENABLE_FLAG" id="supplierInfoList-enabledFlag" v-model="queryParam.enabledFlag" allowClear placeholder="请选择启用状态"></v-select>
  15. </a-form-item>
  16. </a-col>
  17. <a-col :md="6" :sm="24">
  18. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="supplierInfoList-refresh">查询</a-button>
  19. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="supplierInfoList-reset">重置</a-button>
  20. </a-col>
  21. </a-row>
  22. </a-form>
  23. </div>
  24. <!-- 操作按钮 -->
  25. <div class="table-operator">
  26. <a-button
  27. v-if="$hasPermissions('B_supplier_supplierInfo_add')"
  28. id="supplierInfoList-add"
  29. type="primary"
  30. class="button-error"
  31. @click="handleEdit()">新增</a-button>
  32. </div>
  33. <!-- 列表 -->
  34. <s-table
  35. class="sTable fixPagination"
  36. ref="table"
  37. :style="{ height: tableHeight+84.5+'px' }"
  38. size="small"
  39. :rowKey="(record) => record.id"
  40. :columns="columns"
  41. :data="loadData"
  42. :scroll="{ y: tableHeight }"
  43. :defaultLoadData="false"
  44. bordered>
  45. <!-- 操作 -->
  46. <template slot="action" slot-scope="text, record">
  47. <a-button
  48. v-if="$hasPermissions('B_supplier_supplierInfo_edit') && record.tenantId!=0"
  49. size="small"
  50. type="link"
  51. class="button-primary"
  52. @click="handleEdit(record)"
  53. id="supplierInfoList-edit-btn">编辑</a-button>
  54. <span v-else>--</span>
  55. </template>
  56. </s-table>
  57. <!-- 供应商 -->
  58. <supplier-info-edit-modal :itemId="itemId" :openModal="openModal" @close="closeModal" />
  59. </a-card>
  60. </template>
  61. <script>
  62. import { STable, VSelect } from '@/components'
  63. import { supplierList } from '@/api/supplier'
  64. import supplierInfoEditModal from './editModal.vue'
  65. import { commonMixin } from '@/utils/mixin'
  66. export default {
  67. name: 'SupplierList',
  68. components: { STable, VSelect, supplierInfoEditModal },
  69. mixins: [commonMixin],
  70. data () {
  71. return {
  72. queryParam: { // 查询条件
  73. supplierName: '', // 供应商名称
  74. enabledFlag: undefined // 状态
  75. },
  76. tableHeight: 0,
  77. disabled: false, // 查询、重置按钮是否可操作
  78. columns: [
  79. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  80. { title: '供应商名称', dataIndex: 'supplierName', width: '17%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  81. { title: '地址', dataIndex: 'address', width: '15%', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  82. { title: '联系人', dataIndex: 'contactPerson', width: '13%', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  83. { title: '联系电话', dataIndex: 'contactTel', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  84. { title: '主营内容', dataIndex: 'businessScope', width: '14%', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  85. { title: '创建时间', dataIndex: 'createDate', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  86. { title: '状态', dataIndex: 'enabledFlagDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  87. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  88. ],
  89. // 加载数据方法 必须为 Promise 对象
  90. loadData: parameter => {
  91. this.disabled = true
  92. this.spinning = true
  93. return supplierList(Object.assign(parameter, this.queryParam)).then(res => {
  94. let data
  95. if (res.status == 200) {
  96. data = res.data
  97. const no = (data.pageNo - 1) * data.pageSize
  98. for (var i = 0; i < data.list.length; i++) {
  99. data.list[i].no = no + i + 1
  100. const provinceName = data.list[i].provinceName ? data.list[i].provinceName : ''
  101. const cityName = data.list[i].cityName ? data.list[i].cityName : ''
  102. const countyName = data.list[i].countyName ? data.list[i].countyName : ''
  103. const supplierAddress = data.list[i].supplierAddress ? data.list[i].supplierAddress : ''
  104. data.list[i].address = provinceName + cityName + countyName + supplierAddress
  105. }
  106. this.disabled = false
  107. }
  108. this.spinning = false
  109. return data
  110. })
  111. },
  112. itemId: '', // 当前id
  113. openModal: false // 弹框
  114. }
  115. },
  116. methods: {
  117. // 重置
  118. resetSearchForm () {
  119. this.queryParam.supplierName = ''
  120. this.queryParam.enabledFlag = undefined
  121. this.$refs.table.refresh(true)
  122. },
  123. // 新增/编辑
  124. handleEdit (row) {
  125. this.itemId = row && row.id ? row.id : null
  126. this.openModal = true
  127. },
  128. // 关闭弹框
  129. closeModal () {
  130. this.itemId = ''
  131. this.openModal = false
  132. this.$refs.table.refresh(true)
  133. },
  134. pageInit () {
  135. const _this = this
  136. this.$nextTick(() => { // 页面渲染完成后的回调
  137. _this.setTableH()
  138. })
  139. },
  140. setTableH () {
  141. const tableSearchH = this.$refs.tableSearch.offsetHeight
  142. this.tableHeight = window.innerHeight - tableSearchH - 235
  143. }
  144. },
  145. watch: {
  146. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  147. this.setTableH()
  148. }
  149. },
  150. mounted () {
  151. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  152. this.pageInit()
  153. this.resetSearchForm()
  154. }
  155. },
  156. activated () {
  157. // 如果是新页签打开,则重置当前页面
  158. if (this.$store.state.app.isNewTab) {
  159. this.pageInit()
  160. this.resetSearchForm()
  161. }
  162. },
  163. beforeRouteEnter (to, from, next) {
  164. next(vm => {})
  165. }
  166. }
  167. </script>