list.vue 13 KB

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