list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <template>
  2. <a-card size="small" :bordered="false" class="productInfoList-wrap">
  3. <!-- 搜索条件 -->
  4. <div ref="tableSearch" 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. <ProductBrand id="productInfoList-productBrandSn" placeholder="请选择产品品牌" v-model="queryParam.productBrandSn"></ProductBrand>
  26. </a-select>
  27. </a-form-item>
  28. </a-col>
  29. <!-- <a-col :md="6" :sm="24">
  30. <a-form-item label="产品分类">
  31. <ProductType id="productInfoList-productType" placeholder="请选择产品分类" :isDealer="true" @change="changeProductType" v-model="productType"></ProductType>
  32. </a-form-item>
  33. </a-col> -->
  34. <!-- <a-col :md="6" :sm="24">
  35. <a-form-item label="状态">
  36. <v-select code="ONLINE_FLAG" id="productInfoList-onlineFalg" v-model="queryParam.onlineFalg" allowClear placeholder="请选择状态"></v-select>
  37. </a-form-item>
  38. </a-col> -->
  39. </template>
  40. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  41. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="productInfoList-refresh">查询</a-button>
  42. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="productInfoList-reset">重置</a-button>
  43. <!-- <a-button
  44. style="margin: 0 0 18px 8px"
  45. type="danger"
  46. @click="handleExport"
  47. :disabled="disabled"
  48. :loading="exportLoading"
  49. id="inventoryQueryList-export">导出</a-button> -->
  50. <a @click="advanced=!advanced" style="margin-left: 5px">
  51. {{ advanced ? '收起' : '展开' }}
  52. <a-icon :type="advanced ? 'up' : 'down'"/>
  53. </a>
  54. </a-col>
  55. </a-row>
  56. </a-form>
  57. </div>
  58. <!-- 列表 -->
  59. <s-table
  60. class="sTable fixPagination"
  61. ref="table"
  62. :style="{ height: tableHeight+84.5+'px' }"
  63. size="small"
  64. :rowKey="(record) => record.id"
  65. :columns="columns"
  66. :data="loadData"
  67. :scroll="{ y: tableHeight }"
  68. :defaultLoadData="false"
  69. bordered>
  70. <!-- 产品图片 -->
  71. <template slot="imageUrl" slot-scope="text, record">
  72. <div v-if="record.productPicList && record.productPicList.length>0">
  73. <img :src="record.productPicList[0].imageUrl+'?x-oss-process=image/resize,h_30,m_lfit' || ''" width="30" height="30" class="imageUrl" @click="inited(record.productPicList)" />
  74. </div>
  75. <span v-else>--</span>
  76. </template>
  77. <!-- 产品分类 -->
  78. <template slot="productType" slot-scope="text, record">
  79. <span v-if="record.productTypeName2 || record.productTypeName3">{{ record.productTypeName2 }} {{ record.productTypeName3 ? '>' : '' }} {{ record.productTypeName3 }}</span>
  80. <span v-else>--</span>
  81. </template>
  82. <template slot="action" slot-scope="text, record">
  83. <a-button
  84. size="small"
  85. type="link"
  86. class="button-success"
  87. @click="handleDetail(record)"
  88. id="productInfoList-detail-btn">详情</a-button>
  89. </template>
  90. </s-table>
  91. </a-card>
  92. </template>
  93. <script>
  94. import { commonMixin } from '@/utils/mixin'
  95. import { productList, getCurrentDealer } from '@/api/product'
  96. import ProductType from '../../common/productType.js'
  97. import ProductBrand from '../../common/productBrand.js'
  98. import { STable, VSelect } from '@/components'
  99. // import { downloadExcel } from '@/libs/JGPrint.js'
  100. export default {
  101. name: 'ProductJgList',
  102. components: { STable, VSelect, ProductType, ProductBrand },
  103. mixins: [commonMixin],
  104. data () {
  105. return {
  106. advanced: true, // 高级搜索 展开/关闭
  107. tableHeight: 0,
  108. productType: [],
  109. queryParam: { // 查询条件
  110. code: '', // 产品编码
  111. name: '', // 产品名称
  112. origCode: '', // 原厂编码
  113. sysFlag: '1',
  114. productBrandSn: undefined, // 产品品牌
  115. productTypeSn1: '', // 产品一级分类
  116. productTypeSn2: '', // 产品二级分类
  117. productTypeSn3: '', // 产品三级分类
  118. onlineFalg: '1'
  119. },
  120. disabled: false, // 查询、重置按钮是否可操作
  121. exportLoading: false, // 导出loading
  122. dateFormat: 'YYYY-MM-DD',
  123. columns: [],
  124. // 加载数据方法 必须为 Promise 对象
  125. loadData: parameter => {
  126. this.disabled = true
  127. this.spinning = true
  128. return productList(Object.assign(parameter, this.queryParam)).then(res => {
  129. let data
  130. if (res.status == 200) {
  131. data = res.data
  132. const no = (data.pageNo - 1) * data.pageSize
  133. for (var i = 0; i < data.list.length; i++) {
  134. data.list[i].no = no + i + 1
  135. }
  136. this.disabled = false
  137. }
  138. this.spinning = false
  139. return data
  140. })
  141. },
  142. openModal: false, // 查看客户详情 弹框
  143. itemId: '', // 当前产品id
  144. productTypeList: [] // 分类下拉数据
  145. }
  146. },
  147. methods: {
  148. inited (viewer) {
  149. if (viewer) {
  150. const imageUrl = []
  151. viewer.map(item => {
  152. imageUrl.push(item.imageUrl)
  153. })
  154. this.$viewerApi({
  155. images: imageUrl
  156. })
  157. }
  158. },
  159. // 详情
  160. handleDetail (row) {
  161. this.$router.push({ name: 'viewProduct', params: { sn: row.productSn } })
  162. },
  163. // 重置
  164. resetSearchForm () {
  165. this.queryParam.code = ''
  166. this.queryParam.name = ''
  167. this.queryParam.origCode = ''
  168. this.queryParam.productBrandSn = undefined
  169. this.queryParam.productTypeSn1 = ''
  170. this.queryParam.productTypeSn2 = ''
  171. this.queryParam.productTypeSn3 = ''
  172. this.queryParam.onlineFalg = '1'
  173. this.productType = []
  174. this.$refs.table.refresh(true)
  175. },
  176. // 设置表头
  177. getColumns () {
  178. this.columns = [
  179. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  180. { title: '产品编码', dataIndex: 'code', width: '18%', align: 'center', customRender: function (text) { return text || '--' } },
  181. { title: '产品名称', dataIndex: 'name', width: '18%', align: 'center', customRender: function (text) { return text || '--' } },
  182. { title: '原厂编码', dataIndex: 'origCode', width: '17%', align: 'center', customRender: function (text) { return (!text || text == ' ') ? '--' : text } }
  183. // { title: '产品品牌', dataIndex: 'productBrandName', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
  184. // { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: 120, align: 'center' }
  185. ]
  186. const cArr = [
  187. { title: '终端价', dataIndex: 'terminalPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  188. { title: '车主价', dataIndex: 'carOwnersPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  189. { title: '产品图片', scopedSlots: { customRender: 'imageUrl' }, width: '6%', align: 'center' },
  190. // { title: '创建时间', dataIndex: 'createDate', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  191. // { title: '状态', dataIndex: 'onlineFalgDictValue', width: 60, align: 'center', customRender: function (text) { return text || '--' } },
  192. { title: '操作', scopedSlots: { customRender: 'action' }, width: '7%', align: 'center' }
  193. ]
  194. getCurrentDealer().then(res => {
  195. if (res.status == 200) {
  196. if (res.data.dealerLevel && res.data.dealerLevel == 'PROVINCE') { // 省级
  197. this.columns.push(
  198. { title: '省级价', dataIndex: 'provincePrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  199. { title: '市级价', dataIndex: 'cityPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  200. )
  201. } else if (res.data.dealerLevel && res.data.dealerLevel == 'CITY') { // 市级
  202. this.columns.push(
  203. { title: '市级价', dataIndex: 'cityPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  204. )
  205. }
  206. if (res.data.isShowSpecialPrice && res.data.isShowSpecialPrice == '1') { // 是否展示特约价
  207. this.columns.push({ title: '特约价', dataIndex: 'specialPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  208. }
  209. this.columns = [...this.columns, ...cArr]
  210. }
  211. })
  212. },
  213. filterOption (input, option) {
  214. return (
  215. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  216. )
  217. },
  218. // 产品分类 change
  219. changeProductType (val, opt) {
  220. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  221. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  222. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  223. },
  224. // 导出
  225. handleExport () {
  226. this.exportLoading = true
  227. // dealerProductExport(this.queryParam).then(res => {
  228. // this.exportLoading = false
  229. // downloadExcel(res, '箭冠产品列表')
  230. // })
  231. },
  232. pageInit () {
  233. const _this = this
  234. this.$nextTick(() => { // 页面渲染完成后的回调
  235. _this.setTableH()
  236. })
  237. this.getColumns()
  238. },
  239. setTableH () {
  240. const tableSearchH = this.$refs.tableSearch.offsetHeight
  241. this.tableHeight = window.innerHeight - tableSearchH - 195
  242. }
  243. },
  244. watch: {
  245. advanced (newValue, oldValue) {
  246. const _this = this
  247. this.$nextTick(() => { // 页面渲染完成后的回调
  248. _this.setTableH()
  249. })
  250. },
  251. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  252. this.setTableH()
  253. }
  254. },
  255. mounted () {
  256. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  257. this.pageInit()
  258. this.resetSearchForm()
  259. }
  260. },
  261. activated () {
  262. // 如果是新页签打开,则重置当前页面
  263. if (this.$store.state.app.isNewTab) {
  264. this.pageInit()
  265. this.resetSearchForm()
  266. }
  267. },
  268. beforeRouteEnter (to, from, next) {
  269. next(vm => {})
  270. }
  271. }
  272. </script>