list.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. <template>
  2. <a-card size="small" :bordered="false" class="priceInquiryList-wrap">
  3. <!-- 搜索条件 -->
  4. <div ref="tableSearch" class="table-page-search-wrapper">
  5. <a-form-model
  6. ref="ruleForm"
  7. class="form-model-con"
  8. layout="inline"
  9. :rules="rules"
  10. :model="queryParam"
  11. @keyup.enter.native="$refs.table.refresh(true)" >
  12. <a-row :gutter="15">
  13. <a-col :md="6" :sm="24">
  14. <a-form-model-item label="车架号(VIN)" prop="vinCode">
  15. <a-input id="priceInquiryList-vinCode" v-model.trim="queryParam.vinCode" allowClear placeholder="请输入车架号(VIN)">
  16. <a-icon @click="uploadFun" :type="vinLoading?'loading':'camera'" slot="addonAfter" :style="{ fontSize: '18px', verticalAlign: 'bottom' }" />
  17. </a-input>
  18. <input type="file" id="filed" accept="image/jpeg,image/png" hidden="" @change="filePreview">
  19. </a-form-model-item>
  20. </a-col>
  21. <a-col :md="6" :sm="24">
  22. <a-form-model-item label="产品编码">
  23. <a-input id="priceInquiryList-code" v-model.trim="queryParam.code" allowClear placeholder="请输入产品编码"/>
  24. </a-form-model-item>
  25. </a-col>
  26. <a-col :md="6" :sm="24">
  27. <a-form-model-item label="产品名称">
  28. <a-input id="priceInquiryList-name" v-model.trim="queryParam.name" allowClear placeholder="请输入产品名称"/>
  29. </a-form-model-item>
  30. </a-col>
  31. <template v-if="advanced">
  32. <a-col :md="6" :sm="24">
  33. <a-form-model-item label="产品分类">
  34. <a-cascader
  35. @change="changeProductType"
  36. change-on-select
  37. v-model="productType"
  38. expand-trigger="hover"
  39. :options="productTypeList"
  40. :fieldNames="{ label: 'productTypeName', value: 'productTypeSn', children: 'children' }"
  41. id="priceInquiryList-productType"
  42. placeholder="请选择产品分类"
  43. allowClear />
  44. </a-form-model-item>
  45. </a-col>
  46. <a-col :md="6" :sm="24">
  47. <a-form-model-item label="产品品牌">
  48. <ProductBrand id="priceInquiryList-productBrandSn" v-model="queryParam.productBrandSn"></ProductBrand>
  49. </a-form-model-item>
  50. </a-col>
  51. <a-col :md="6" :sm="24">
  52. <a-form-model-item label="产品状态">
  53. <v-select code="PRODUCT_ONOFFLINE_STATUS" id="priceInquiryList-state" v-model="queryParam.state" allowClear placeholder="请选择状态"></v-select>
  54. </a-form-model-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="priceInquiryList-refresh">查询</a-button>
  59. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="priceInquiryList-reset">重置</a-button>
  60. <a @click="advanced=!advanced" style="margin-left: 5px">
  61. {{ advanced ? '收起' : '展开' }}
  62. <a-icon :type="advanced ? 'up' : 'down'"/>
  63. </a>
  64. </a-col>
  65. </a-row>
  66. </a-form-model>
  67. </div>
  68. <a-alert type="error" style="margin-bottom: 10px;" v-if="vinInfoData&&!vinInfoData.vinInfo">
  69. <template slot="message"><a-icon type="exclamation-circle" theme="filled" :style="{ color: '#E70012', fontSize: '15px', verticalAlign: 'sub', marginRight: '3px' }" />抱歉!暂未找到匹配VIN码的车型!</template>
  70. </a-alert>
  71. <a-alert type="warning" style="margin-bottom: 10px;cursor: pointer;" v-if="vinInfoData&&vinInfoData.vinInfo" @click="openCarInfoModal=true">
  72. <template slot="message">
  73. <div style="display: flex;justify-content: space-between;align-items: center;" @click="openCarInfoModal=true">
  74. <div>
  75. <img :src="vinInfoData.vinInfo && vinInfoData.vinInfo.icon?(vinInfoData.vinInfo.icon+'?x-oss-process=image/resize,h_30,m_lfit'):defImg" width="30" height="30" class="imageUrl" style="border-radius: 50%;vertical-align: middle;margin-right: 3px;" />
  76. <span style="vertical-align: middle;">{{ vinInfoData.vinInfo.text }}</span>
  77. </div>
  78. <div style="color: #f90;">
  79. <span>查看更多</span> >
  80. </div>
  81. </div>
  82. </template>
  83. </a-alert>
  84. <!-- 列表 -->
  85. <s-table
  86. class="sTable fixPagination"
  87. ref="table"
  88. :style="{ height: tableHeight+84.5+'px' }"
  89. size="small"
  90. :rowKey="(record) => record.id"
  91. :columns="columns"
  92. :data="loadData"
  93. :scroll="{ y: tableHeight }"
  94. :defaultLoadData="false"
  95. bordered>
  96. <!-- 产品图片 -->
  97. <template slot="imageUrl" slot-scope="text, record">
  98. <div v-if="record.productPicList && record.productPicList.length>0">
  99. <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)" />
  100. </div>
  101. <span v-else>--</span>
  102. </template>
  103. <!-- 产品分类 -->
  104. <template slot="productType" slot-scope="text, record">
  105. <span v-if="record.productTypeName2 || record.productTypeName3">{{ record.productTypeName2 }} {{ record.productTypeName3 ? '>' : '' }} {{ record.productTypeName3 }}</span>
  106. <span v-else>--</span>
  107. </template>
  108. <!-- 产品编码 可点击查看详情 -->
  109. <template slot="detail" slot-scope="text, record">
  110. <span class="link-bule" @click="handleDetail(record)">{{ record.code }}</span>
  111. </template>
  112. </s-table>
  113. <!-- 查看车辆信息 -->
  114. <car-info-modal v-drag ref="carInfoModal" :openModal="openCarInfoModal" :infoData="vinInfoData&&vinInfoData.vinInfo" @close="openCarInfoModal=false" />
  115. </a-card>
  116. </template>
  117. <script>
  118. import { commonMixin } from '@/utils/mixin'
  119. import { STable, VSelect } from '@/components'
  120. import carInfoModal from './carInfoModal.vue'
  121. import { productBrandQuery } from '@/api/productBrand'
  122. import { productTypeQuery } from '@/api/productType'
  123. import { productPriceList } from '@/api/product'
  124. import { supperCodeByVin, vinCodeParse } from '@/api/sales'
  125. import ProductBrand from '@/views/common/productBrand.js'
  126. export default {
  127. name: 'PriceInquiryList',
  128. mixins: [commonMixin],
  129. components: { STable, VSelect, ProductBrand, carInfoModal },
  130. data () {
  131. return {
  132. advanced: true, // 高级搜索 展开/关闭
  133. vinLoading: false,
  134. tableHeight: 0,
  135. productType: [],
  136. queryParam: { // 查询条件
  137. code: '', // 产品编码
  138. name: '', // 产品名称
  139. vinCode: '',
  140. codeList: undefined, // 车架号
  141. productBrandSn: undefined, // 产品品牌
  142. productTypeSn1: '', // 产品一级分类
  143. productTypeSn2: '', // 产品二级分类
  144. productTypeSn3: '', // 产品三级分类
  145. state: 'ONLINE' // 产品状态
  146. },
  147. rules: {
  148. vinCode: [ { len: 17, message: '请输入正确的车架号(VIN)', trigger: 'change' } ]
  149. },
  150. disabled: false, // 查询、重置按钮是否可操作
  151. // 加载数据方法 必须为 Promise 对象
  152. loadData: parameter => {
  153. const _this = this
  154. const params = Object.assign(parameter, _this.queryParam)
  155. if (_this.queryParam.vinCode && _this.queryParam.vinCode.length == 17 && !this.onlyList) { // 输入vin,查出vin码信息后请求列表数据
  156. _this.disabled = true
  157. return supperCodeByVin({ vin: _this.queryParam.vinCode }).then(res => {
  158. if (res.status == 200) {
  159. _this.vinInfoData = res.data
  160. params.codeList = res.data.partCodeList || []
  161. return _this.getList(params)
  162. } else {
  163. _this.vinInfoData = null
  164. _this.$refs.table.localLoading = false
  165. _this.$refs.table.clearTable()
  166. }
  167. })
  168. } else if (_this.queryParam.vinCode && _this.queryParam.vinCode.length < 17 && !this.onlyList) { // 输入vin,但vin码不符合标准,不查vin码信息,不请求列表数据
  169. _this.$refs.table.localLoading = false
  170. _this.$refs.table.clearTable()
  171. } else if (this.onlyList) {
  172. _this.disabled = true
  173. if (_this.queryParam.vinCode && _this.vinInfoData) {
  174. return _this.getList(Object.assign(params, { codeList: _this.vinInfoData.partCodeList }))
  175. } else {
  176. return _this.getList(params)
  177. }
  178. } else { // 未输入vin码信息,只查列表数据
  179. _this.disabled = true
  180. return _this.getList(params)
  181. }
  182. },
  183. vinInfoData: null,
  184. productBrandList: [], // 品牌下拉数据
  185. productTypeList: [], // 分类下拉数据
  186. openCarInfoModal: false,
  187. onlyList: false
  188. }
  189. },
  190. computed: {
  191. columns () {
  192. const arr = [
  193. { title: '产品编码', dataIndex: 'code', scopedSlots: { customRender: 'detail' }, width: '15%', align: 'center' },
  194. { title: '产品名称', dataIndex: 'name', width: '15%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  195. { title: '原厂编码', dataIndex: 'origCode', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
  196. { title: '产品状态', dataIndex: 'stateDictValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  197. ]
  198. if (this.$hasPermissions('M_priceInquiryList_provincePrice')) { // 售价权限
  199. arr.push({ title: '省级价', dataIndex: 'provincePrice', width: '8%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') })
  200. }
  201. if (this.$hasPermissions('M_priceInquiryList_cityPrice')) { // 售价权限
  202. arr.push({ title: '市级价', dataIndex: 'cityPrice', width: '8%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') })
  203. }
  204. if (this.$hasPermissions('M_priceInquiryList_specialPrice')) { // 售价权限
  205. arr.push({ title: '特约价', dataIndex: 'specialPrice', width: '8%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') })
  206. }
  207. arr.push({ title: '终端价', dataIndex: 'terminalPrice', width: '8%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') })
  208. arr.push({ title: '车主价', dataIndex: 'carOwnersPrice', width: '8%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') })
  209. arr.push({ title: '产品图片', scopedSlots: { customRender: 'imageUrl' }, width: '8%', align: 'center' })
  210. return arr
  211. }
  212. },
  213. methods: {
  214. // 详情
  215. handleDetail (row) {
  216. this.itemId = row.productSn
  217. this.$router.push({ name: 'viewProduct', params: { sn: row.productSn } })
  218. },
  219. getList (params) {
  220. const _this = this
  221. return productPriceList(params).then(res => {
  222. let data
  223. this.onlyList = false
  224. if (res.status == 200) {
  225. data = res.data
  226. data.list = data.list.filter(item => item != null)
  227. const no = (data.pageNo - 1) * data.pageSize
  228. for (var i = 0; i < data.list.length; i++) {
  229. data.list[i].no = no + i + 1
  230. }
  231. if (!params.vinCode) {
  232. _this.vinInfoData = null
  233. }
  234. } else {
  235. data = {
  236. list: [],
  237. pageNo: 1,
  238. pageSize: 10
  239. }
  240. }
  241. _this.disabled = false
  242. return data
  243. })
  244. },
  245. inited (viewer) {
  246. if (viewer) {
  247. const imageUrl = []
  248. viewer.map(item => {
  249. imageUrl.push(item.imageUrl)
  250. })
  251. this.$viewerApi({
  252. images: imageUrl
  253. })
  254. }
  255. },
  256. // 重置
  257. resetSearchForm () {
  258. this.queryParam.code = ''
  259. this.queryParam.name = ''
  260. this.queryParam.productBrandSn = undefined
  261. this.queryParam.productTypeSn1 = ''
  262. this.queryParam.productTypeSn2 = ''
  263. this.queryParam.productTypeSn3 = ''
  264. this.queryParam.state = 'ONLINE'
  265. this.queryParam.codeList = undefined
  266. this.productType = []
  267. this.$refs.ruleForm.resetFields()
  268. this.$refs.table.refresh(true)
  269. this.vinInfoData = null
  270. },
  271. uploadFun () {
  272. document.getElementById('filed').click()
  273. },
  274. filePreview (e) {
  275. const _this = this
  276. var files = e.target.files[0]
  277. const formData = new FormData()
  278. formData.append('savePathType', 'local')
  279. formData.append('file', files)
  280. this.vinLoading = true
  281. vinCodeParse(formData).then(res => {
  282. if (res.type == 'application/json') {
  283. var reader = new FileReader()
  284. reader.addEventListener('loadend', function () {
  285. const obj = JSON.parse(reader.result)
  286. if (obj.status == 200) {
  287. _this.queryParam.vinCode = obj.data || ''
  288. // 移除表单项的校验结果
  289. _this.$refs.ruleForm.clearValidate('vinCode')
  290. } else {
  291. _this.$notification.error({
  292. message: '提示',
  293. description: obj.message
  294. })
  295. }
  296. _this.vinLoading = false
  297. document.getElementById('filed').value = ''
  298. })
  299. reader.readAsText(res)
  300. } else {
  301. _this.vinLoading = false
  302. }
  303. })
  304. },
  305. // 产品分类 change
  306. changeProductType (val, opt) {
  307. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  308. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  309. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  310. },
  311. // 产品品牌 列表
  312. getProductBrand () {
  313. productBrandQuery({}).then(res => {
  314. if (res.status == 200) {
  315. this.productBrandList = res.data
  316. } else {
  317. this.productBrandList = []
  318. }
  319. })
  320. },
  321. // 产品分类 列表
  322. getProductType () {
  323. productTypeQuery({}).then(res => {
  324. if (res.status == 200) {
  325. this.productTypeList = res.data
  326. } else {
  327. this.productTypeList = []
  328. }
  329. })
  330. },
  331. pageInit () {
  332. const _this = this
  333. this.$nextTick(() => { // 页面渲染完成后的回调
  334. _this.setTableH()
  335. })
  336. this.getProductBrand()
  337. this.getProductType()
  338. },
  339. setTableH () {
  340. const tableSearchH = this.$refs.tableSearch.offsetHeight
  341. this.tableHeight = window.innerHeight - tableSearchH - 195
  342. }
  343. },
  344. watch: {
  345. advanced (newValue, oldValue) {
  346. const _this = this
  347. this.$nextTick(() => { // 页面渲染完成后的回调
  348. _this.setTableH()
  349. })
  350. },
  351. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  352. this.setTableH()
  353. }
  354. },
  355. mounted () {
  356. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  357. this.pageInit()
  358. this.resetSearchForm()
  359. }
  360. },
  361. activated () {
  362. // 如果是新页签打开,则重置当前页面
  363. if (this.$store.state.app.isNewTab) {
  364. this.pageInit()
  365. this.resetSearchForm()
  366. }
  367. // 仅刷新列表,不重置页面
  368. if (this.$store.state.app.updateList) {
  369. this.pageInit()
  370. this.$refs.table.refresh()
  371. }
  372. },
  373. beforeRouteEnter (to, from, next) {
  374. next(vm => {})
  375. }
  376. }
  377. </script>