queryPart.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  1. <template>
  2. <div class="productInfoList-wrap">
  3. <!-- 搜索条件 -->
  4. <div 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 type="flex" :gutter="5">
  13. <a-col :lg="4" :md="6" :sm="12">
  14. <a-form-model-item label="产品编码">
  15. <a-input id="productInfoList-code" ref="searchProductCode" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码"/>
  16. </a-form-model-item>
  17. </a-col>
  18. <a-col :lg="4" :md="6" :sm="12">
  19. <a-form-model-item label="产品名称">
  20. <a-input id="productInfoList-name" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
  21. </a-form-model-item>
  22. </a-col>
  23. <a-col :lg="4" :md="6" :sm="12">
  24. <a-form-model-item label="原厂编码">
  25. <a-input id="productInfoList-origCode" v-model.trim="queryParam.productOrigCode" allowClear placeholder="请输入原厂编码"/>
  26. </a-form-model-item>
  27. </a-col>
  28. <a-col :lg="4" :md="6" :sm="12">
  29. <a-form-model-item label="产品分类">
  30. <ProductType id="productInfoList-productType" :isDealer="true" @change="changeProductType" v-model="productType"></ProductType>
  31. </a-form-model-item>
  32. </a-col>
  33. <template v-if="advanced">
  34. <a-col :lg="4" :md="6" :sm="12">
  35. <a-form-model-item label="产品品牌">
  36. <ProductBrand id="productInfoList-productBrandSn" v-model="queryParam.brandSn"></ProductBrand>
  37. </a-form-model-item>
  38. </a-col>
  39. <a-col :lg="4" :md="6" :sm="12">
  40. <a-form-model-item label="仓库">
  41. <a-select
  42. placeholder="请选择仓库"
  43. id="productInfoList-warehouseSn"
  44. allowClear
  45. v-model="queryParam.warehouseSn"
  46. :showSearch="true"
  47. option-filter-prop="children"
  48. :filter-option="filterOption">
  49. <a-select-option v-for="item in warehouseList" :key="item.warehouseSn" :value="item.warehouseSn">{{ item.name }}</a-select-option>
  50. </a-select>
  51. </a-form-model-item>
  52. </a-col>
  53. <a-col :lg="6" :md="8" :sm="12" v-if="$hasPermissions('B_salerVinFindProduct')">
  54. <a-form-model-item label="车架号(VIN)" prop="vinCode">
  55. <a-input id="productInfoList-vinCode" v-model.trim="queryParam.vinCode" allowClear placeholder="请输入车架号(VIN)">
  56. <a-icon @click="uploadFun" :type="vinLoading?'loading':'camera'" slot="addonAfter" :style="{ fontSize: '18px', verticalAlign: 'bottom' }" />
  57. </a-input>
  58. <input type="file" id="filed" accept="image/jpeg,image/png" hidden="" @change="filePreview">
  59. </a-form-model-item>
  60. </a-col>
  61. <a-col :md="6" :sm="24">
  62. <a-form-item label="是否有库存">
  63. <a-select @change="handleHasQty" allowClear :value="queryParam.existStockFlag" placeholder="请选择查看是否有库存">
  64. <a-select-option value="1">
  65. </a-select-option>
  66. <a-select-option value="0">
  67. </a-select-option>
  68. </a-select>
  69. </a-form-item>
  70. </a-col>
  71. </template>
  72. <a-col flex="200px" style="margin-bottom: 10px;">
  73. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="productInfoList-refresh">查询</a-button>
  74. <a-button style="margin-left: 5px" @click="resetSearchForm" id="productInfoList-reset">重置</a-button>
  75. <a @click="advanced=!advanced" style="margin:0 0 0 10px">
  76. {{ advanced ? '收起' : '展开' }}
  77. <a-icon :type="advanced ? 'up' : 'down'"/>
  78. </a>
  79. </a-col>
  80. <a-col flex="auto" style="margin-bottom: 15px;display:flex;align-items:center;">
  81. <a-checkbox v-model="cost" v-if="$hasPermissions('M_ShowAllCost')" id="salesQuery-cost">成本价</a-checkbox>
  82. <a-checkbox v-model="cityPrice" v-if="$hasPermissions('M_ShowAllCityPrice')&&$store.state.user.dealerLevel != 'SPECIAL'" id="salesQuery-cityPrice">市级价</a-checkbox>
  83. <a-checkbox v-model="tyuePrice" v-if="$store.state.user.isShowSpecialPrice==1" id="salesQuery-tyuePrice">特约价</a-checkbox>
  84. <a-checkbox v-model="zdPrice" id="salesQuery-zdPrice">终端价</a-checkbox>
  85. </a-col>
  86. </a-row>
  87. </a-form-model>
  88. </div>
  89. <a-alert type="error" style="margin-bottom: 10px;" v-if="vinInfoData&&!vinInfoData.vinInfo">
  90. <template slot="message"><a-icon type="exclamation-circle" :style="{ color: '#E70012', fontSize: '15px', verticalAlign: 'sub', marginRight: '3px' }" />抱歉!暂未找到匹配VIN码的车型!</template>
  91. </a-alert>
  92. <a-alert type="warning" style="margin-bottom: 10px;cursor: pointer;" v-if="vinInfoData&&vinInfoData.vinInfo" @click="openCarInfoModal=true">
  93. <template slot="message">
  94. <div style="display: flex;justify-content: space-between;align-items: center;" @click="openCarInfoModal=true">
  95. <div>
  96. <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;" />
  97. <span style="vertical-align: middle;">{{ vinInfoData.vinInfo.text }}</span>
  98. </div>
  99. <div style="color: #f90;">
  100. <span>查看更多</span> >
  101. </div>
  102. </div>
  103. </template>
  104. </a-alert>
  105. <!-- 列表 -->
  106. <s-table
  107. class="sTable"
  108. ref="table"
  109. size="small"
  110. :rowKey="(record) => record.no"
  111. rowKeyName="no"
  112. :columns="columns"
  113. :data="loadData"
  114. @dblclick="handleClickRow"
  115. :defaultLoadData="false"
  116. :pageSize="10"
  117. :scroll="{ y: 149 }"
  118. bordered>
  119. <div slot="costTitle">
  120. <a-tooltip placement="top">
  121. <template slot="title">
  122. 产品所在仓库仓位的最近一次入库成本,不包含盘盈入库和仓库调拨入库。
  123. </template>
  124. <span style="margin-right: 5px;">参考成本价</span> <a-icon type="question-circle" />
  125. </a-tooltip>
  126. </div>
  127. <!-- 售价 -->
  128. <template slot="salePrice" slot-scope="text, record">
  129. <div style="display: flex;align-items: center;" @dblclick.stop>
  130. <a-input-number
  131. size="small"
  132. v-model="record.price"
  133. :precision="2"
  134. :min="0"
  135. :max="999999"
  136. style="width: 100%;"
  137. placeholder="请输入" />
  138. <span style="color: red;margin: 0 2px;font-size: 14px;" v-if="record.origSalePriceFlag == 1">原</span>
  139. <span v-else>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
  140. </div>
  141. </template>
  142. <!-- 销售数量 -->
  143. <template slot="nums" slot-scope="text, record">
  144. <div @dblclick.stop>
  145. <a-input-number
  146. size="small"
  147. v-model="record.salesNums"
  148. :precision="0"
  149. :min="0"
  150. :max="999999"
  151. style="width: 100%;"
  152. placeholder="请输入" />
  153. </div>
  154. </template>
  155. <!-- 操作 -->
  156. <template slot="action" slot-scope="text, record">
  157. <a-button
  158. size="small"
  159. type="link"
  160. class="button-primary"
  161. @click="handleAdd(record)"
  162. id="productInfoList-edit-btn">添加</a-button>
  163. <a-button
  164. size="small"
  165. type="link"
  166. class="button-primary"
  167. @click="handleDetail(record)"
  168. id="productInfoList-detail-btn"
  169. style="margin-left: 5px;">销售记录</a-button>
  170. </template>
  171. </s-table>
  172. <!-- 销售记录 -->
  173. <product-salesRecord-modal ref="salseRecord" :openModal="openModal" @close="closeModal" />
  174. <!-- 查看车辆信息 -->
  175. <car-info-modal ref="carInfoModal" :openModal="openCarInfoModal" :infoData="vinInfoData&&vinInfoData.vinInfo" @close="openCarInfoModal=false" />
  176. </div>
  177. </template>
  178. <script>
  179. import { commonMixin } from '@/utils/mixin'
  180. import { querySumByProductLocation } from '@/api/stock'
  181. import { warehouseAllList } from '@/api/warehouse'
  182. import productSalesRecordModal from './productSalesRecordModal.vue'
  183. import carInfoModal from './carInfoModal.vue'
  184. import ProductType from '../../common/productType.js'
  185. import ProductBrand from '../../common/productBrand.js'
  186. import { STable, VSelect, Upload } from '@/components'
  187. import { supperCodeByVin, vinCodeParse } from '@/api/sales'
  188. import defImg from '@/assets/def_img@2x.png'
  189. export default {
  190. name: 'QueryPart',
  191. components: { STable, VSelect, Upload, productSalesRecordModal, carInfoModal, ProductType, ProductBrand },
  192. mixins: [commonMixin],
  193. props: {
  194. newLoading: Boolean
  195. },
  196. data () {
  197. return {
  198. advanced: false, // 高级搜索 展开/关闭
  199. vinLoading: false,
  200. productType: [],
  201. defImg,
  202. queryParam: { // 查询条件
  203. customerSn: '',
  204. salesBillSn: '',
  205. salePriceType: '',
  206. productCode: '', // 产品编码
  207. productName: '', // 产品名称
  208. productOrigCode: '', // 原厂编码
  209. vinCode: '',
  210. productCodeList: undefined, // 车架号
  211. brandSn: undefined, // 产品品牌
  212. productTypeSn1: '', // 产品一级分类
  213. productTypeSn2: '', // 产品二级分类
  214. productTypeSn3: '', // 产品三级分类
  215. warehouseSn: undefined, // 仓库、
  216. enableFlag: '1',
  217. existStockFlag: undefined
  218. },
  219. priceType: '',
  220. buyerSn: '',
  221. rules: {
  222. vinCode: [ { len: 17, message: '请输入正确的车架号(VIN)', trigger: 'change' } ]
  223. },
  224. disabled: false, // 查询、重置按钮是否可操作
  225. warehouseList: [], // 仓库列表
  226. vinInfoData: null,
  227. // 加载数据方法 必须为 Promise 对象
  228. loadData: parameter => {
  229. const _this = this
  230. _this.queryParam.salePriceType = _this.priceType
  231. _this.queryParam.customerSn = _this.buyerSn
  232. // 排序
  233. if (parameter.sortField == 'productCode') {
  234. parameter.sortField = 'code'
  235. parameter.sortAlias = 'product '
  236. }
  237. if (parameter.sortField == 'brandName') {
  238. parameter.sortField = 'firstChar'
  239. parameter.sortAlias = 'brand'
  240. }
  241. if (parameter.sortField == 'warehouseName') {
  242. parameter.sortField = 'warehouseSn'
  243. parameter.sortAlias = 'sd'
  244. }
  245. const params = Object.assign(parameter, _this.queryParam)
  246. if (_this.queryParam.vinCode && _this.queryParam.vinCode.length == 17 && !this.onlyList) { // 输入vin,查出vin码信息后请求列表数据
  247. _this.disabled = true
  248. return supperCodeByVin({ vin: _this.queryParam.vinCode }).then(res => {
  249. if (res.status == 200) {
  250. _this.vinInfoData = res.data
  251. params.productCodeList = res.data.partCodeList || []
  252. return _this.getList(params)
  253. } else {
  254. _this.vinInfoData = null
  255. _this.$refs.table.localLoading = false
  256. _this.$refs.table.clearTable()
  257. }
  258. })
  259. } else if (_this.queryParam.vinCode && _this.queryParam.vinCode.length < 17 && !this.onlyList) { // 输入vin,但vin码不符合标准,不查vin码信息,不请求列表数据
  260. _this.$refs.table.localLoading = false
  261. _this.$refs.table.clearTable()
  262. } else if (this.onlyList) {
  263. _this.disabled = true
  264. if (_this.queryParam.vinCode && _this.vinInfoData) {
  265. return _this.getList(Object.assign(params, { productCodeList: _this.vinInfoData.partCodeList }))
  266. } else {
  267. return _this.getList(params)
  268. }
  269. } else { // 未输入vin码信息,只查列表数据
  270. _this.disabled = true
  271. return _this.getList(params)
  272. }
  273. },
  274. openModal: false, // 查看客户详情 弹框
  275. cost: false, // 成本价
  276. cityPrice: false, // 城市价
  277. tyuePrice: false, // 特约价
  278. zdPrice: false, // 终端价
  279. openCarInfoModal: false,
  280. onlyList: false
  281. }
  282. },
  283. computed: {
  284. columns () {
  285. const _this = this
  286. const arr = [
  287. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  288. { title: '产品编码', dataIndex: 'productCode', width: '13%', align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
  289. { title: '产品名称', dataIndex: 'productName', width: '16%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  290. { title: '原厂编码', dataIndex: 'productOrigCode', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  291. { title: '品牌', dataIndex: 'brandName', width: '11%', align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
  292. { title: '仓库', dataIndex: 'warehouseName', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  293. { title: '仓位', dataIndex: 'warehouseLocationName', width: '8%', align: 'center', customRender: function (text) { return text || '--' } }
  294. ]
  295. if (this.cost) {
  296. arr.push({ slots: { title: 'costTitle' }, dataIndex: 'putCost', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  297. }
  298. if (this.cityPrice && this.$hasPermissions('M_ShowAllCityPrice')) {
  299. arr.push({ title: '市级价', dataIndex: 'dealerProduct.cityPrice', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  300. }
  301. if (this.tyuePrice) {
  302. arr.push({ title: '特约价', dataIndex: 'dealerProduct.specialPrice', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  303. }
  304. if (this.zdPrice) {
  305. arr.push({ title: '终端价', dataIndex: 'dealerProduct.terminalPrice', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  306. }
  307. return arr.concat([
  308. { title: '单位', dataIndex: 'unit', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  309. { title: '售价', dataIndex: 'salePrice', scopedSlots: { customRender: 'salePrice' }, width: '7%', align: 'center' },
  310. { title: '销售数量', dataIndex: 'salesNums', scopedSlots: { customRender: 'nums' }, width: '6%', align: 'center' },
  311. { title: '库存数量', dataIndex: 'currentQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  312. { title: '操作', dataIndex: 'action', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  313. ])
  314. }
  315. },
  316. created () {
  317. // 仓库
  318. if (this.warehouseList.length == 0) {
  319. this.getWarehouse()
  320. }
  321. },
  322. methods: {
  323. getList (params) {
  324. const _this = this
  325. return querySumByProductLocation(params).then(res => {
  326. let data
  327. this.onlyList = false
  328. if (res.status == 200) {
  329. data = res.data
  330. data.list = data.list.filter(item => item != null)
  331. const no = (data.pageNo - 1) * data.pageSize
  332. for (var i = 0; i < data.list.length; i++) {
  333. data.list[i].no = no + i + 1
  334. data.list[i].salesNums = 1
  335. data.list[i].currentQty = data.list[i].currentQty || 0
  336. data.list[i].price = data.list[i].origSalePriceFlag == 0 ? data.list[i].lastSalePrice : data.list[i].origSalePriceFlag == 1 ? data.list[i].salePrice : data.list[i].selfSaleprice
  337. data.list[i].productOrigCode = data.list[i].productOrigCode ? data.list[i].productOrigCode.trim() : ''
  338. }
  339. if (!params.vinCode) {
  340. _this.vinInfoData = null
  341. }
  342. } else {
  343. data = {
  344. list: [],
  345. pageNo: 1,
  346. pageSize: 10
  347. }
  348. }
  349. _this.disabled = false
  350. console.log(data)
  351. return data
  352. })
  353. },
  354. // vin change
  355. vinCodeChange (e) {
  356. if (e.target.value.length == 17) {
  357. supperCodeByVin({ vin: e.target.value }).then(res => {
  358. if (res.status == 200) {
  359. this.queryParam.productCodeList = res.data
  360. } else {
  361. this.queryParam.productCodeList = undefined
  362. }
  363. })
  364. } else {
  365. this.queryParam.productCodeList = undefined
  366. }
  367. },
  368. // 双击列表
  369. handleClickRow (record) {
  370. this.$emit('add', record)
  371. },
  372. // 重置
  373. resetSearchForm () {
  374. this.queryParam.productCode = ''
  375. this.queryParam.productName = ''
  376. this.queryParam.productOrigCode = ''
  377. this.queryParam.brandSn = undefined
  378. this.queryParam.productTypeSn1 = ''
  379. this.queryParam.productTypeSn2 = ''
  380. this.queryParam.productTypeSn3 = ''
  381. this.queryParam.warehouseSn = undefined
  382. this.queryParam.productCodeList = undefined
  383. this.queryParam.existStockFlag = undefined
  384. this.queryParam.vinCode = ''
  385. this.productType = []
  386. this.$refs.ruleForm.resetFields()
  387. this.$refs.table.refresh(true)
  388. this.vinInfoData = null
  389. },
  390. pageInit (buyerSn, priceType, salesBillSn) {
  391. this.priceType = priceType || ''
  392. this.buyerSn = buyerSn || ''
  393. this.queryParam.salesBillSn = salesBillSn || ''
  394. if (this.onlyList) { // 不清空查询条件
  395. this.$refs.table.refresh()
  396. } else {
  397. this.resetSearchForm()
  398. }
  399. this.$refs.searchProductCode.focus()
  400. },
  401. // 刷新当前页面
  402. resetCurForm () {
  403. this.$refs.table.refresh()
  404. },
  405. // 清空数据
  406. clearTable () {
  407. this.vinInfoData = null
  408. this.$refs.ruleForm.resetFields()
  409. this.$refs.table.clearTable()
  410. },
  411. filterOption (input, option) {
  412. return (
  413. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  414. )
  415. },
  416. // 选择配件
  417. handleAdd (row) {
  418. const _this = this
  419. console.log(row.price, row.lastSalePrice, row.salePrice, row.lastSalePrice < row.salePrice)
  420. if (row.lastSalePrice && (row.price < row.salePrice)) {
  421. _this.$confirm({
  422. title: '提示',
  423. content: '售价低于定价,是否仍继续添加?',
  424. centered: true,
  425. closable: true,
  426. onOk () {
  427. _this.$emit('add', row)
  428. }
  429. })
  430. } else {
  431. _this.$emit('add', row)
  432. }
  433. },
  434. // 销售记录
  435. handleDetail (row) {
  436. this.openModal = true
  437. this.$refs.salseRecord.getDetail(this.buyerSn, row.productSn, row)
  438. },
  439. // 关闭弹框
  440. closeModal () {
  441. this.openModal = false
  442. },
  443. uploadFun () {
  444. document.getElementById('filed').click()
  445. },
  446. filePreview (e) {
  447. const _this = this
  448. var files = e.target.files[0]
  449. const formData = new FormData()
  450. formData.append('savePathType', 'local')
  451. formData.append('file', files)
  452. this.vinLoading = true
  453. vinCodeParse(formData).then(res => {
  454. if (res.type == 'application/json') {
  455. var reader = new FileReader()
  456. reader.addEventListener('loadend', function () {
  457. const obj = JSON.parse(reader.result)
  458. if (obj.status == 200) {
  459. _this.queryParam.vinCode = obj.data || ''
  460. // 移除表单项的校验结果
  461. _this.$refs.ruleForm.clearValidate('vinCode')
  462. } else {
  463. _this.$notification.error({
  464. message: '提示',
  465. description: obj.message
  466. })
  467. }
  468. _this.vinLoading = false
  469. document.getElementById('filed').value = ''
  470. })
  471. reader.readAsText(res)
  472. } else {
  473. _this.vinLoading = false
  474. }
  475. })
  476. },
  477. // 仓库
  478. getWarehouse () {
  479. warehouseAllList({ wasteFlag: 0 }).then(res => {
  480. if (res.status == 200) {
  481. this.warehouseList = res.data
  482. } else {
  483. this.warehouseList = []
  484. }
  485. })
  486. },
  487. // 产品分类 change
  488. changeProductType (val, opt) {
  489. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  490. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  491. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  492. },
  493. // 查看是否有库存、
  494. handleHasQty (val) {
  495. this.queryParam.existStockFlag = val
  496. }
  497. },
  498. watch: {
  499. cost (newValue, oldValue) {
  500. this.$emit('isCost', newValue)
  501. }
  502. }
  503. }
  504. </script>