list.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <a-card size="small" :bordered="false" class="supplierInfoList-wrap">
  3. <!-- 搜索条件 -->
  4. <div 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"
  36. ref="table"
  37. size="small"
  38. :rowKey="(record) => record.id"
  39. :columns="columns"
  40. :data="loadData"
  41. :scroll="{ x: 1310, y: tableHeight }"
  42. bordered>
  43. <!-- 操作 -->
  44. <template slot="action" slot-scope="text, record">
  45. <a-button
  46. v-if="$hasPermissions('B_supplier_supplierInfo_edit') && record.tenantId!=0"
  47. size="small"
  48. type="link"
  49. class="button-info"
  50. @click="handleEdit(record)"
  51. id="supplierInfoList-edit-btn">编辑</a-button>
  52. <span v-else>--</span>
  53. </template>
  54. </s-table>
  55. <!-- 供应商 -->
  56. <supplier-info-edit-modal :itemId="itemId" :openModal="openModal" @close="closeModal" />
  57. </a-card>
  58. </template>
  59. <script>
  60. import { STable, VSelect } from '@/components'
  61. import { supplierList } from '@/api/supplier'
  62. import supplierInfoEditModal from './editModal.vue'
  63. export default {
  64. components: { STable, VSelect, supplierInfoEditModal },
  65. data () {
  66. return {
  67. queryParam: { // 查询条件
  68. supplierName: '', // 供应商名称
  69. enabledFlag: undefined // 状态
  70. },
  71. tableHeight: 0,
  72. disabled: false, // 查询、重置按钮是否可操作
  73. columns: [
  74. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  75. { title: '供应商名称', dataIndex: 'supplierName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  76. { title: '地址', dataIndex: 'address', width: 200, align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  77. { title: '联系人', dataIndex: 'contactPerson', width: 150, align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  78. { title: '联系电话', dataIndex: 'contactTel', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
  79. { title: '主营内容', dataIndex: 'businessScope', width: 200, align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  80. { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  81. { title: '状态', dataIndex: 'enabledFlagDictValue', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  82. { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
  83. ],
  84. // 加载数据方法 必须为 Promise 对象
  85. loadData: parameter => {
  86. this.disabled = true
  87. if (this.tableHeight == 0) {
  88. this.tableHeight = window.innerHeight - 360
  89. }
  90. return supplierList(Object.assign(parameter, this.queryParam)).then(res => {
  91. const data = res.data
  92. const no = (data.pageNo - 1) * data.pageSize
  93. for (var i = 0; i < data.list.length; i++) {
  94. data.list[i].no = no + i + 1
  95. const provinceName = data.list[i].provinceName ? data.list[i].provinceName : ''
  96. const cityName = data.list[i].cityName ? data.list[i].cityName : ''
  97. const countyName = data.list[i].countyName ? data.list[i].countyName : ''
  98. const supplierAddress = data.list[i].supplierAddress ? data.list[i].supplierAddress : ''
  99. data.list[i].address = provinceName + cityName + countyName + supplierAddress
  100. }
  101. this.disabled = false
  102. return data
  103. })
  104. },
  105. itemId: '', // 当前id
  106. openModal: false // 弹框
  107. }
  108. },
  109. methods: {
  110. // 重置
  111. resetSearchForm () {
  112. this.queryParam.supplierName = ''
  113. this.queryParam.enabledFlag = undefined
  114. this.$refs.table.refresh(true)
  115. },
  116. // 新增/编辑
  117. handleEdit (row) {
  118. this.itemId = row && row.id ? row.id : null
  119. this.openModal = true
  120. },
  121. // 关闭弹框
  122. closeModal () {
  123. this.itemId = ''
  124. this.openModal = false
  125. this.$refs.table.refresh(true)
  126. }
  127. }
  128. }
  129. </script>