list.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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="default"
  38. :rowKey="(record) => record.id"
  39. :columns="columns"
  40. :data="loadData"
  41. :customRow="handleClickRow"
  42. :scroll="{ x: 1310, y: 300 }"
  43. bordered>
  44. <!-- 操作 -->
  45. <template slot="action" slot-scope="text, record">
  46. <a-button
  47. v-if="$hasPermissions('B_supplier_supplierInfo_edit')"
  48. size="small"
  49. type="primary"
  50. class="button-info"
  51. @click="handleEdit(record)"
  52. id="supplierInfoList-edit-btn">编辑</a-button>
  53. </template>
  54. <!-- 状态 -->
  55. <template slot="status" slot-scope="text, record">
  56. <span :style="{color:(record.enabledFlag==1?'#00aa00':'#999')}">{{ record.enabledFlagDictValue }}</span>
  57. </template>
  58. </s-table>
  59. </a-card>
  60. </template>
  61. <script>
  62. import { STable, VSelect } from '@/components'
  63. import { supplierList } from '@/api/supplier'
  64. export default {
  65. components: { STable, VSelect },
  66. data () {
  67. return {
  68. queryParam: { // 查询条件
  69. supplierName: '', // 供应商名称
  70. enabledFlag: undefined // 状态
  71. },
  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: '状态', scopedSlots: { customRender: 'status' }, width: 100, align: 'center' },
  82. { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
  83. ],
  84. // 加载数据方法 必须为 Promise 对象
  85. loadData: parameter => {
  86. this.disabled = true
  87. return supplierList(Object.assign(parameter, this.queryParam)).then(res => {
  88. const data = res.data
  89. const no = (data.pageNo - 1) * data.pageSize
  90. for (var i = 0; i < data.list.length; i++) {
  91. data.list[i].no = no + i + 1
  92. const provinceName = data.list[i].provinceName ? data.list[i].provinceName : ''
  93. const cityName = data.list[i].cityName ? data.list[i].cityName : ''
  94. const countyName = data.list[i].countyName ? data.list[i].countyName : ''
  95. const supplierAddress = data.list[i].supplierAddress ? data.list[i].supplierAddress : ''
  96. data.list[i].address = provinceName + cityName + countyName + supplierAddress
  97. }
  98. this.disabled = false
  99. return data
  100. })
  101. }
  102. }
  103. },
  104. methods: {
  105. handleClickRow (record) {
  106. return {
  107. on: {
  108. dblclick: (event) => {
  109. console.log(record)
  110. }
  111. }
  112. }
  113. },
  114. // 重置
  115. resetSearchForm () {
  116. this.queryParam.supplierName = ''
  117. this.queryParam.enabledFlag = undefined
  118. this.$refs.table.refresh(true)
  119. },
  120. // 新增/编辑
  121. handleEdit (row) {
  122. if (row) { // 编辑
  123. this.$router.push({ path: `/supplierManagement/supplierInfo/edit/${row.id}` })
  124. } else { // 新增
  125. this.$router.push({ path: '/supplierManagement/supplierInfo/add' })
  126. }
  127. }
  128. }
  129. }
  130. </script>