list.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template>
  2. <a-card size="small" :bordered="false" class="productInfoList-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="productInfoList-code" v-model.trim="queryParam.code" allowClear placeholder="请输入产品编码"/>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="24">
  13. <a-form-item label="产品名称">
  14. <a-input id="productInfoList-name" v-model.trim="queryParam.name" allowClear placeholder="请输入产品名称"/>
  15. </a-form-item>
  16. </a-col>
  17. <a-col :md="6" :sm="24">
  18. <a-form-item label="原厂编码">
  19. <a-input id="productInfoList-origCode" v-model.trim="queryParam.origCode" allowClear placeholder="请输入原厂编码"/>
  20. </a-form-item>
  21. </a-col>
  22. <template v-if="advanced">
  23. <a-col :md="6" :sm="24">
  24. <a-form-item label="产品品牌">
  25. <a-select
  26. placeholder="请选择产品品牌"
  27. id="productInfoList-productBrandSn"
  28. allowClear
  29. v-model="queryParam.productBrandSn"
  30. :showSearch="true"
  31. option-filter-prop="children"
  32. :filter-option="filterOption">
  33. <a-select-option v-for="item in productBrandList" :key="item.brandSn" :value="item.brandSn">{{ item.brandName }}</a-select-option>
  34. </a-select>
  35. </a-form-item>
  36. </a-col>
  37. <a-col :md="6" :sm="24">
  38. <a-form-item label="产品分类">
  39. <a-cascader
  40. @change="changeProductType"
  41. change-on-select
  42. v-model="productType"
  43. expand-trigger="hover"
  44. :options="productTypeList"
  45. :fieldNames="{ label: 'productTypeName', value: 'productTypeSn', children: 'children' }"
  46. id="productInfoList-productType"
  47. placeholder="请选择产品分类"
  48. allowClear />
  49. </a-form-item>
  50. </a-col>
  51. <a-col :md="6" :sm="24">
  52. <a-form-item label="状态">
  53. <v-select code="ONLINE_FLAG" id="productInfoList-onlineFalg" v-model="queryParam.onlineFalg" allowClear placeholder="请选择状态"></v-select>
  54. </a-form-item>
  55. </a-col>
  56. </template>
  57. <a-col :md="6" :sm="24">
  58. <a-button style="margin-bottom: 18px;" type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="productInfoList-refresh">查询</a-button>
  59. <a-button style="margin: 0 0 18px 8px" @click="resetSearchForm" :disabled="disabled" id="productInfoList-reset">重置</a-button>
  60. <!-- <a-button
  61. style="margin: 0 0 18px 8px"
  62. type="danger"
  63. @click="handleExport"
  64. :disabled="disabled"
  65. :loading="exportLoading"
  66. id="inventoryQueryList-export">导出</a-button> -->
  67. <a @click="advanced=!advanced" style="margin-left: 8px">
  68. {{ advanced ? '收起' : '展开' }}
  69. <a-icon :type="advanced ? 'up' : 'down'"/>
  70. </a>
  71. </a-col>
  72. </a-row>
  73. </a-form>
  74. </div>
  75. <!-- 列表 -->
  76. <s-table
  77. class="sTable"
  78. ref="table"
  79. size="default"
  80. :rowKey="(record) => record.id"
  81. :columns="columns"
  82. :data="loadData"
  83. :scroll="{ x: 1340, y: tableHeight }"
  84. bordered>
  85. <!-- 产品分类 -->
  86. <template slot="productType" slot-scope="text, record">
  87. <span v-if="record.productTypeName2 || record.productTypeName3">{{ record.productTypeName2 }} {{ record.productTypeName3 ? '>' : '' }} {{ record.productTypeName3 }}</span>
  88. <span v-else>--</span>
  89. </template>
  90. <!-- 状态 -->
  91. <template slot="onlineFalgDictValue" slot-scope="text, record">
  92. <a-badge :color="record.onlineFalgDictValue == '下架'?'#ccc':'green'" :text="record.onlineFalgDictValue" />
  93. </template>
  94. </s-table>
  95. </a-card>
  96. </template>
  97. <script>
  98. import moment from 'moment'
  99. import { dealerProductBrandQuery } from '@/api/dealerProductBrand'
  100. import { productTypeQuery } from '@/api/productType'
  101. import { productList } from '@/api/product'
  102. import { STable, VSelect } from '@/components'
  103. export default {
  104. components: { STable, VSelect },
  105. data () {
  106. return {
  107. advanced: false, // 高级搜索 展开/关闭
  108. tableHeight: 0,
  109. productType: [],
  110. queryParam: { // 查询条件
  111. code: '', // 产品编码
  112. name: '', // 产品名称
  113. origCode: '', // 原厂编码
  114. sysFlag: '1',
  115. productBrandSn: undefined, // 产品品牌
  116. productTypeSn1: '', // 产品一级分类
  117. productTypeSn2: '', // 产品二级分类
  118. productTypeSn3: '', // 产品三级分类
  119. onlineFalg: undefined // 状态
  120. },
  121. disabled: false, // 查询、重置按钮是否可操作
  122. exportLoading: false, // 导出loading
  123. dateFormat: 'YYYY-MM-DD',
  124. columns: [
  125. { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
  126. { title: '产品编码', dataIndex: 'code', width: 140, align: 'center' },
  127. { title: '产品名称', dataIndex: 'name', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  128. { title: '原厂编码', dataIndex: 'origCode', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  129. { title: '产品品牌', dataIndex: 'productBrandName', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  130. { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: 240, align: 'center' },
  131. { title: '终端价', dataIndex: 'terminalPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  132. { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center' },
  133. { title: '状态', scopedSlots: { customRender: 'onlineFalgDictValue' }, width: 140, align: 'center' }
  134. ],
  135. // 加载数据方法 必须为 Promise 对象
  136. loadData: parameter => {
  137. this.disabled = true
  138. if (this.tableHeight == 0) {
  139. this.tableHeight = window.innerHeight - 210
  140. }
  141. return productList(Object.assign(parameter, this.queryParam)).then(res => {
  142. const data = res.data
  143. const no = (data.pageNo - 1) * data.pageSize
  144. for (var i = 0; i < data.list.length; i++) {
  145. data.list[i].no = no + i + 1
  146. const productTypeName1 = data.list[i].productTypeName1 ? data.list[i].productTypeName1 : ''
  147. const productTypeName2 = data.list[i].productTypeName2 ? ' > ' + data.list[i].productTypeName2 : ''
  148. const productTypeName3 = data.list[i].productTypeName3 ? ' > ' + data.list[i].productTypeName3 : ''
  149. data.list[i].productTypeName = productTypeName1 + productTypeName2 + productTypeName3
  150. }
  151. this.disabled = false
  152. return data
  153. })
  154. },
  155. openModal: false, // 查看客户详情 弹框
  156. itemId: '', // 当前产品id
  157. productBrandList: [], // 品牌下拉数据
  158. productTypeList: [] // 分类下拉数据
  159. }
  160. },
  161. methods: {
  162. // 重置
  163. resetSearchForm () {
  164. this.queryParam.code = ''
  165. this.queryParam.name = ''
  166. this.queryParam.origCode = ''
  167. this.queryParam.productBrandSn = undefined
  168. this.queryParam.productTypeSn1 = ''
  169. this.queryParam.productTypeSn2 = ''
  170. this.queryParam.productTypeSn3 = ''
  171. this.queryParam.onlineFalg = undefined
  172. this.productType = []
  173. this.$refs.table.refresh(true)
  174. },
  175. filterOption (input, option) {
  176. return (
  177. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  178. )
  179. },
  180. // 产品分类 change
  181. changeProductType (val, opt) {
  182. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  183. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  184. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  185. },
  186. // 导出
  187. handleExport () {
  188. this.exportLoading = true
  189. // dealerProductExport(this.queryParam).then(res => {
  190. // this.exportLoading = false
  191. // this.download(res)
  192. // })
  193. },
  194. download (data) {
  195. if (!data) { return }
  196. const url = window.URL.createObjectURL(new Blob([data]))
  197. const link = document.createElement('a')
  198. link.style.display = 'none'
  199. link.href = url
  200. const a = moment().format('YYYYMMDDHHmmss')
  201. const fname = '箭冠产品列表' + a
  202. link.setAttribute('download', fname + '.xlsx')
  203. document.body.appendChild(link)
  204. link.click()
  205. },
  206. // 产品品牌 列表
  207. getProductBrand () {
  208. dealerProductBrandQuery({ 'sysFlag': '1' }).then(res => {
  209. if (res.status == 200) {
  210. this.productBrandList = res.data
  211. } else {
  212. this.productBrandList = []
  213. }
  214. })
  215. },
  216. // 产品分类 列表
  217. getProductType () {
  218. productTypeQuery({}).then(res => {
  219. if (res.status == 200) {
  220. this.productTypeList = res.data
  221. } else {
  222. this.productTypeList = []
  223. }
  224. })
  225. }
  226. },
  227. beforeRouteEnter (to, from, next) {
  228. next(vm => {
  229. vm.getProductBrand()
  230. vm.getProductType()
  231. })
  232. }
  233. }
  234. </script>