list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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: 1940, 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, getCurrentDealer } 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. // 加载数据方法 必须为 Promise 对象
  126. loadData: parameter => {
  127. this.disabled = true
  128. if (this.tableHeight == 0) {
  129. this.tableHeight = window.innerHeight - 210
  130. }
  131. return productList(Object.assign(parameter, this.queryParam)).then(res => {
  132. const data = res.data
  133. const no = (data.pageNo - 1) * data.pageSize
  134. for (var i = 0; i < data.list.length; i++) {
  135. data.list[i].no = no + i + 1
  136. }
  137. this.disabled = false
  138. return data
  139. })
  140. },
  141. openModal: false, // 查看客户详情 弹框
  142. itemId: '', // 当前产品id
  143. productBrandList: [], // 品牌下拉数据
  144. productTypeList: [] // 分类下拉数据
  145. }
  146. },
  147. methods: {
  148. // 重置
  149. resetSearchForm () {
  150. this.queryParam.code = ''
  151. this.queryParam.name = ''
  152. this.queryParam.origCode = ''
  153. this.queryParam.productBrandSn = undefined
  154. this.queryParam.productTypeSn1 = ''
  155. this.queryParam.productTypeSn2 = ''
  156. this.queryParam.productTypeSn3 = ''
  157. this.queryParam.onlineFalg = undefined
  158. this.productType = []
  159. this.$refs.table.refresh(true)
  160. },
  161. // 设置表头
  162. getColumns () {
  163. this.columns = [
  164. { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
  165. { title: '产品编码', dataIndex: 'code', align: 'center' },
  166. { title: '产品名称', dataIndex: 'name', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  167. { title: '原厂编码', dataIndex: 'origCode', align: 'center', customRender: function (text) { return text || '--' } },
  168. { title: '产品品牌', dataIndex: 'productBrandName', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
  169. { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: 200, align: 'center' }
  170. ]
  171. const cArr = [
  172. { title: '终端价', dataIndex: 'terminalPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  173. { title: '车主价', dataIndex: 'carOwnersPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  174. { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center' },
  175. { title: '状态', scopedSlots: { customRender: 'onlineFalgDictValue' }, width: 140, align: 'center' }
  176. ]
  177. getCurrentDealer().then(res => {
  178. if (res.status == 200) {
  179. if (res.data.dealerLevel && res.data.dealerLevel == 'PROVINCE') { // 省级
  180. this.columns.push(
  181. { title: '省级价', dataIndex: 'provincePrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  182. { title: '市级价', dataIndex: 'cityPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  183. )
  184. } else if (res.data.dealerLevel && res.data.dealerLevel == 'CITY') { // 市级
  185. this.columns.push(
  186. { title: '市级价', dataIndex: 'cityPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  187. )
  188. }
  189. if (res.data.isShowSpecialPrice && res.data.isShowSpecialPrice == '1') { // 是否展示特约价
  190. this.columns.push({ title: '特约价', dataIndex: 'specialPrice', width: 100, align: 'center' })
  191. }
  192. this.columns = [...this.columns, ...cArr]
  193. }
  194. })
  195. },
  196. filterOption (input, option) {
  197. return (
  198. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  199. )
  200. },
  201. // 产品分类 change
  202. changeProductType (val, opt) {
  203. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  204. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  205. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  206. },
  207. // 导出
  208. handleExport () {
  209. this.exportLoading = true
  210. // dealerProductExport(this.queryParam).then(res => {
  211. // this.exportLoading = false
  212. // this.download(res)
  213. // })
  214. },
  215. download (data) {
  216. if (!data) { return }
  217. const url = window.URL.createObjectURL(new Blob([data]))
  218. const link = document.createElement('a')
  219. link.style.display = 'none'
  220. link.href = url
  221. const a = moment().format('YYYYMMDDHHmmss')
  222. const fname = '箭冠产品列表' + a
  223. link.setAttribute('download', fname + '.xlsx')
  224. document.body.appendChild(link)
  225. link.click()
  226. },
  227. // 产品品牌 列表
  228. getProductBrand () {
  229. dealerProductBrandQuery({ 'sysFlag': '1' }).then(res => {
  230. if (res.status == 200) {
  231. this.productBrandList = res.data
  232. } else {
  233. this.productBrandList = []
  234. }
  235. })
  236. },
  237. // 产品分类 列表
  238. getProductType () {
  239. productTypeQuery({}).then(res => {
  240. if (res.status == 200) {
  241. this.productTypeList = res.data
  242. } else {
  243. this.productTypeList = []
  244. }
  245. })
  246. }
  247. },
  248. beforeRouteEnter (to, from, next) {
  249. next(vm => {
  250. vm.getColumns()
  251. vm.getProductBrand()
  252. vm.getProductType()
  253. })
  254. }
  255. }
  256. </script>