list.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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-bundleName" v-model.trim="queryParam.bundleName" 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="CHECK_ENABLE_STATE" id="supplierInfoList-state" v-model="queryParam.state" 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 id="supplierInfoList-add" type="primary" @click="handleEdit()">新增供应商</a-button>
  27. </div>
  28. <!-- 列表 -->
  29. <s-table
  30. class="sTable"
  31. ref="table"
  32. size="default"
  33. :rowKey="(record) => record.id"
  34. :columns="columns"
  35. :data="loadData"
  36. :customRow="handleClickRow"
  37. :scroll="{ x: 1260 }"
  38. bordered>
  39. <!-- 状态 -->
  40. <template slot="state" slot-scope="text, record">
  41. <a-tag :color="record.state==1?'green':'red'" >{{ record.state==1? '已启用': '已禁用' }}</a-tag>
  42. </template>
  43. <!-- 操作 -->
  44. <template slot="action" slot-scope="text, record">
  45. <a-button size="small" type="link" @click="handleEdit(record)" id="supplierInfoList-edit-btn">编辑</a-button>
  46. </template>
  47. </s-table>
  48. </a-card>
  49. </template>
  50. <script>
  51. // import { getProvince, getCityByPro, getDistrictByCity } from '@/api/data'
  52. import { STable, VSelect } from '@/components'
  53. export default {
  54. components: { STable, VSelect },
  55. data () {
  56. return {
  57. queryParam: { // 查询条件
  58. bundleName: '', // 供应商名称
  59. state: undefined // 状态
  60. },
  61. disabled: false, // 查询、重置按钮是否可操作
  62. columns: [
  63. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  64. { title: '供应商名称', dataIndex: 'productName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  65. { title: '地址', dataIndex: 'productOldNum', width: 200, align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  66. { title: '联系人', dataIndex: 'productBrand', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  67. { title: '联系电话', dataIndex: 'productType', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
  68. { title: '主营内容', dataIndex: 'inventoryNum', width: 200, align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  69. { title: '创建时间', dataIndex: 'inventoryMoney', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  70. { title: '状态', scopedSlots: { customRender: 'state' }, width: 100, align: 'center' },
  71. { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
  72. ],
  73. // 加载数据方法 必须为 Promise 对象
  74. loadData: parameter => {
  75. this.disabled = true
  76. // return customerBundleDelayList( Object.assign(parameter, this.queryParam) ).then(res => {
  77. // const data = res.data
  78. // const no = (data.pageNo - 1) * data.pageSize
  79. // for (var i = 0; i < data.list.length; i++) {
  80. // data.list[i].no = no + i + 1
  81. // }
  82. // this.disabled = false
  83. // return data
  84. // })
  85. const _this = this
  86. return new Promise(function (resolve, reject) {
  87. const data = {
  88. pageNo: 1,
  89. pageSize: 10,
  90. list: [
  91. { id: '1', productNum: 'jgqp11111111111', productName: '产品1', productOldNum: 'jgqp111123545', productBrand: '箭冠品牌', productType: '产品分类1', inventoryNum: '5', inventoryMoney: '122' }
  92. ]
  93. }
  94. const no = (data.pageNo - 1) * data.pageSize
  95. for (var i = 0; i < data.list.length; i++) {
  96. data.list[i].no = no + i + 1
  97. }
  98. _this.disabled = false
  99. resolve(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.orderBundleNo = ''
  117. this.queryParam.orderBundle.custMobile = ''
  118. this.queryParam.bundleName = ''
  119. this.queryParam.itemName = ''
  120. this.oldTime = undefined
  121. this.newTime = undefined
  122. this.$refs.table.refresh(true)
  123. },
  124. // 新增/编辑
  125. handleEdit (row) {
  126. if (row) { // 编辑
  127. this.$router.push({ path: `/supplierManagement/supplierInfo/edit/${row.id}` })
  128. } else { // 新增
  129. this.$router.push({ path: '/supplierManagement/supplierInfo/add' })
  130. }
  131. }
  132. }
  133. }
  134. </script>