list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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. <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" style="margin-bottom: 10px;">
  58. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="productInfoList-refresh">查询</a-button>
  59. <a-button style="margin-left: 5px" @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: 5px">
  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 fixPagination"
  78. ref="table"
  79. :style="{ height: tableHeight+84.5+'px' }"
  80. size="small"
  81. :rowKey="(record) => record.id"
  82. :columns="columns"
  83. :data="loadData"
  84. :scroll="{ x: 1540, y: tableHeight }"
  85. :defaultLoadData="false"
  86. bordered>
  87. <!-- 产品图片 -->
  88. <template slot="imageUrl" slot-scope="text, record">
  89. <div v-if="record.productPicList && record.productPicList.length>0">
  90. <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)" />
  91. </div>
  92. <span v-else>--</span>
  93. </template>
  94. <!-- 产品分类 -->
  95. <template slot="productType" slot-scope="text, record">
  96. <span v-if="record.productTypeName2 || record.productTypeName3">{{ record.productTypeName2 }} {{ record.productTypeName3 ? '>' : '' }} {{ record.productTypeName3 }}</span>
  97. <span v-else>--</span>
  98. </template>
  99. <template slot="action" slot-scope="text, record">
  100. <a-button
  101. size="small"
  102. type="link"
  103. class="button-success"
  104. @click="handleDetail(record)"
  105. id="productInfoList-detail-btn">详情</a-button>
  106. </template>
  107. </s-table>
  108. </a-card>
  109. </template>
  110. <script>
  111. import moment from 'moment'
  112. import { dealerProductBrandQuery } from '@/api/dealerProductBrand'
  113. import { productTypeQuery } from '@/api/productType'
  114. import { productList, getCurrentDealer } from '@/api/product'
  115. import { STable, VSelect } from '@/components'
  116. export default {
  117. name: 'ProductJgList',
  118. components: { STable, VSelect },
  119. data () {
  120. return {
  121. advanced: true, // 高级搜索 展开/关闭
  122. tableHeight: 0,
  123. productType: [],
  124. queryParam: { // 查询条件
  125. code: '', // 产品编码
  126. name: '', // 产品名称
  127. origCode: '', // 原厂编码
  128. sysFlag: '1',
  129. productBrandSn: undefined, // 产品品牌
  130. productTypeSn1: '', // 产品一级分类
  131. productTypeSn2: '', // 产品二级分类
  132. productTypeSn3: '', // 产品三级分类
  133. onlineFalg: '1'
  134. },
  135. disabled: false, // 查询、重置按钮是否可操作
  136. exportLoading: false, // 导出loading
  137. dateFormat: 'YYYY-MM-DD',
  138. columns: [],
  139. // 加载数据方法 必须为 Promise 对象
  140. loadData: parameter => {
  141. this.disabled = true
  142. this.spinning = true
  143. return productList(Object.assign(parameter, this.queryParam)).then(res => {
  144. const data = res.data
  145. const no = (data.pageNo - 1) * data.pageSize
  146. for (var i = 0; i < data.list.length; i++) {
  147. data.list[i].no = no + i + 1
  148. }
  149. this.disabled = false
  150. this.spinning = false
  151. return data
  152. })
  153. },
  154. openModal: false, // 查看客户详情 弹框
  155. itemId: '', // 当前产品id
  156. productBrandList: [], // 品牌下拉数据
  157. productTypeList: [] // 分类下拉数据
  158. }
  159. },
  160. methods: {
  161. inited (viewer) {
  162. if (viewer) {
  163. const imageUrl = []
  164. viewer.map(item => {
  165. imageUrl.push(item.imageUrl)
  166. })
  167. this.$viewerApi({
  168. images: imageUrl
  169. })
  170. }
  171. },
  172. // 详情
  173. handleDetail (row) {
  174. this.$router.push({ name: 'viewProduct', params: { sn: row.productSn } })
  175. },
  176. // 重置
  177. resetSearchForm () {
  178. this.queryParam.code = ''
  179. this.queryParam.name = ''
  180. this.queryParam.origCode = ''
  181. this.queryParam.productBrandSn = undefined
  182. this.queryParam.productTypeSn1 = ''
  183. this.queryParam.productTypeSn2 = ''
  184. this.queryParam.productTypeSn3 = ''
  185. this.queryParam.onlineFalg = '1'
  186. this.productType = []
  187. this.$refs.table.refresh(true)
  188. },
  189. // 设置表头
  190. getColumns () {
  191. this.columns = [
  192. { title: '序号', dataIndex: 'no', width: 70, align: 'center' },
  193. { title: '产品编码', dataIndex: 'code', align: 'center', width: 250, customRender: function (text) { return text || '--' } },
  194. { title: '产品名称', dataIndex: 'name', align: 'center', customRender: function (text) { return text || '--' } },
  195. { title: '原厂编码', dataIndex: 'origCode', align: 'center', width: 120, customRender: function (text) { return (!text || text == ' ') ? '--' : text } },
  196. { title: '产品图片', scopedSlots: { customRender: 'imageUrl' }, width: 80, align: 'center' }
  197. // { title: '产品品牌', dataIndex: 'productBrandName', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
  198. // { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: 120, align: 'center' }
  199. ]
  200. const cArr = [
  201. { title: '终端价', dataIndex: 'terminalPrice', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  202. { title: '车主价', dataIndex: 'carOwnersPrice', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  203. // { title: '创建时间', dataIndex: 'createDate', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  204. // { title: '状态', dataIndex: 'onlineFalgDictValue', width: 60, align: 'center', customRender: function (text) { return text || '--' } },
  205. { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
  206. ]
  207. getCurrentDealer().then(res => {
  208. if (res.status == 200) {
  209. if (res.data.dealerLevel && res.data.dealerLevel == 'PROVINCE') { // 省级
  210. this.columns.push(
  211. { title: '省级价', dataIndex: 'provincePrice', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  212. { title: '市级价', dataIndex: 'cityPrice', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  213. )
  214. } else if (res.data.dealerLevel && res.data.dealerLevel == 'CITY') { // 市级
  215. this.columns.push(
  216. { title: '市级价', dataIndex: 'cityPrice', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  217. )
  218. }
  219. if (res.data.isShowSpecialPrice && res.data.isShowSpecialPrice == '1') { // 是否展示特约价
  220. this.columns.push({ title: '特约价', dataIndex: 'specialPrice', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  221. }
  222. this.columns = [...this.columns, ...cArr]
  223. }
  224. })
  225. },
  226. filterOption (input, option) {
  227. return (
  228. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  229. )
  230. },
  231. // 产品分类 change
  232. changeProductType (val, opt) {
  233. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  234. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  235. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  236. },
  237. // 导出
  238. handleExport () {
  239. this.exportLoading = true
  240. // dealerProductExport(this.queryParam).then(res => {
  241. // this.exportLoading = false
  242. // this.download(res)
  243. // })
  244. },
  245. download (data) {
  246. if (!data) { return }
  247. const url = window.URL.createObjectURL(new Blob([data]))
  248. const link = document.createElement('a')
  249. link.style.display = 'none'
  250. link.href = url
  251. const a = moment().format('YYYYMMDDHHmmss')
  252. const fname = '箭冠产品列表' + a
  253. link.setAttribute('download', fname + '.xlsx')
  254. document.body.appendChild(link)
  255. link.click()
  256. },
  257. // 产品品牌 列表
  258. getProductBrand () {
  259. dealerProductBrandQuery({ 'sysFlag': '1' }).then(res => {
  260. if (res.status == 200) {
  261. this.productBrandList = res.data
  262. } else {
  263. this.productBrandList = []
  264. }
  265. })
  266. },
  267. // 产品分类 列表
  268. getProductType () {
  269. productTypeQuery({}).then(res => {
  270. if (res.status == 200) {
  271. this.productTypeList = res.data
  272. } else {
  273. this.productTypeList = []
  274. }
  275. })
  276. },
  277. pageInit () {
  278. const _this = this
  279. this.$nextTick(() => { // 页面渲染完成后的回调
  280. _this.setTableH()
  281. })
  282. this.getColumns()
  283. this.getProductBrand()
  284. this.getProductType()
  285. },
  286. setTableH () {
  287. const tableSearchH = this.$refs.tableSearch.offsetHeight
  288. this.tableHeight = window.innerHeight - tableSearchH - 195
  289. }
  290. },
  291. watch: {
  292. advanced (newValue, oldValue) {
  293. const _this = this
  294. setTimeout(() => {
  295. _this.setTableH()
  296. }, 400)
  297. }
  298. },
  299. mounted () {
  300. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  301. this.pageInit()
  302. this.resetSearchForm()
  303. }
  304. },
  305. activated () {
  306. // 如果是新页签打开,则重置当前页面
  307. if (this.$store.state.app.isNewTab) {
  308. this.pageInit()
  309. this.resetSearchForm()
  310. }
  311. },
  312. beforeRouteEnter (to, from, next) {
  313. next(vm => {})
  314. }
  315. }
  316. </script>