queryPart.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  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 :gutter="15">
  13. <a-col :md="6" :sm="24">
  14. <a-form-model-item label="产品编码">
  15. <a-input id="productInfoList-code" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码"/>
  16. </a-form-model-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  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 :md="5" :sm="24">
  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. <template v-if="advanced">
  29. <a-col :md="7" :sm="24">
  30. <a-form-model-item label="车架号(VIN)" prop="vinNo">
  31. <a-input id="productInfoList-vinNo" v-model.trim="queryParam.vinNo" @change="vinNoChange" allowClear placeholder="请输入车架号(VIN)"/>
  32. </a-form-model-item>
  33. </a-col>
  34. <a-col :md="6" :sm="24">
  35. <a-form-model-item label="产品品牌">
  36. <a-select
  37. placeholder="请选择产品品牌"
  38. id="productInfoList-productBrandSn"
  39. allowClear
  40. v-model="queryParam.brandSn"
  41. :showSearch="true"
  42. option-filter-prop="children"
  43. :filter-option="filterOption">
  44. <a-select-option v-for="item in productBrandList" :key="item.brandSn" :value="item.brandSn">{{ item.brandName }}</a-select-option>
  45. </a-select>
  46. </a-form-model-item>
  47. </a-col>
  48. <a-col :md="6" :sm="24">
  49. <a-form-model-item label="产品分类">
  50. <a-cascader
  51. @change="changeProductType"
  52. change-on-select
  53. v-model="productType"
  54. expand-trigger="hover"
  55. :options="productTypeList"
  56. :fieldNames="{ label: 'productTypeName', value: 'productTypeSn', children: 'children' }"
  57. id="productInfoList-productType"
  58. placeholder="请选择产品分类"
  59. allowClear />
  60. </a-form-model-item>
  61. </a-col>
  62. <!-- <a-col :md="6" :sm="24">
  63. <a-form-item label="车型">
  64. <v-select code="CHECK_ENABLE_STATE" id="productInfoList-state" v-model="queryParam.state" allowClear placeholder="请选择车型"></v-select>
  65. </a-form-item>
  66. </a-col> -->
  67. <a-col :md="5" :sm="24">
  68. <a-form-model-item label="仓库">
  69. <a-select
  70. placeholder="请选择仓库"
  71. id="productInfoList-warehouseSn"
  72. allowClear
  73. v-model="queryParam.warehouseSn"
  74. :showSearch="true"
  75. option-filter-prop="children"
  76. :filter-option="filterOption">
  77. <a-select-option v-for="item in warehouseList" :key="item.warehouseSn" :value="item.warehouseSn">{{ item.name }}</a-select-option>
  78. </a-select>
  79. </a-form-model-item>
  80. </a-col>
  81. </template>
  82. <a-col :md="7" :sm="24">
  83. <a-button style="margin-bottom: 18px;" type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="productInfoList-refresh">查询</a-button>
  84. <a-button style="margin: 0 0 18px 8px" @click="resetSearchForm" id="productInfoList-reset">重置</a-button>
  85. <a @click="advanced=!advanced" style="margin:0 15px 0 8px">
  86. {{ advanced ? '收起' : '展开' }}
  87. <a-icon :type="advanced ? 'up' : 'down'"/>
  88. </a>
  89. <a-popover>
  90. <template slot="content">双击列表配件可快速选中添加</template>
  91. <a-icon type="question-circle" theme="twoTone" />
  92. </a-popover>
  93. <a-popover>
  94. <template slot="content">点击设置列的显示</template>
  95. <a-icon style="margin:0 5px;cursor: pointer;" @click="showSetting = true" type="setting" theme="twoTone" />
  96. </a-popover>
  97. </a-col>
  98. </a-row>
  99. </a-form-model>
  100. </div>
  101. <!-- 列表 -->
  102. <s-table
  103. class="sTable"
  104. ref="table"
  105. size="small"
  106. :rowKey="(record) => record.id"
  107. :columns="columns"
  108. :data="loadData"
  109. :customRow="handleClickRow"
  110. :scroll="{ x: tableWidth, y: 300 }"
  111. :defaultLoadData="false"
  112. bordered>
  113. <!-- 售价 -->
  114. <template slot="salePrice" slot-scope="text, record">
  115. <div @dblclick.stop>
  116. <a-input-number
  117. size="small"
  118. v-model="record.salePrice"
  119. :precision="2"
  120. :min="0"
  121. :max="999999"
  122. placeholder="请输入" />
  123. </div>
  124. </template>
  125. <!-- 销售数量 -->
  126. <template slot="nums" slot-scope="text, record">
  127. <div @dblclick.stop>
  128. <a-input-number
  129. size="small"
  130. v-model="record.salesNums"
  131. :precision="0"
  132. :min="0"
  133. :max="999999"
  134. placeholder="请输入" />
  135. </div>
  136. </template>
  137. <!-- 操作 -->
  138. <template slot="action" slot-scope="text, record">
  139. <a-button
  140. size="small"
  141. type="primary"
  142. class="button-info"
  143. @click="handleAdd(record)"
  144. id="productInfoList-edit-btn">添加</a-button>
  145. <a-button
  146. size="small"
  147. type="primary"
  148. class="button-success"
  149. @click="handleDetail(record)"
  150. id="productInfoList-detail-btn"
  151. style="margin-left: 5px;">销售记录</a-button>
  152. </template>
  153. </s-table>
  154. <!-- 销售记录 -->
  155. <product-salesRecord-modal ref="salseRecord" :openModal="openModal" @close="closeModal" />
  156. <!-- 设置列 -->
  157. <a-modal
  158. v-model="showSetting"
  159. title="设置要显示的列"
  160. centered
  161. :footer="null"
  162. @ok="() => (showSetting = false)"
  163. >
  164. <a-checkbox-group v-model="settingColVal" @change="onSettingChange">
  165. <a-row>
  166. <a-col :span="8" v-for="item in settingColList" :key="item.value">
  167. <a-checkbox :value="item.value">
  168. {{ item.label }}
  169. </a-checkbox>
  170. </a-col>
  171. </a-row>
  172. </a-checkbox-group>
  173. </a-modal>
  174. </div>
  175. </template>
  176. <script>
  177. import { dealerProductBrandQuery } from '@/api/dealerProductBrand'
  178. import { dealerProductTypeList } from '@/api/dealerProductType'
  179. import { querySumByProductLocation } from '@/api/stock'
  180. import { warehouseAllList } from '@/api/warehouse'
  181. import productSalesRecordModal from './productSalesRecordModal.vue'
  182. import { STable, VSelect } from '@/components'
  183. import { supperCodeByVin } from '@/api/sales'
  184. export default {
  185. name: 'QueryPart',
  186. components: { STable, VSelect, productSalesRecordModal },
  187. props: {
  188. buyerSn: {
  189. type: [Number, String],
  190. default: ''
  191. },
  192. priceType: {
  193. type: [Number, String],
  194. default: ''
  195. },
  196. newLoading: Boolean
  197. },
  198. data () {
  199. return {
  200. advanced: false, // 高级搜索 展开/关闭
  201. showSetting: false, // 设置弹框
  202. tableWidth: 0,
  203. settingColVal: ['productOrigCode', 'brandName', 'warehouseName', 'warehouseLocationName', 'currentQty', 'unit'],
  204. settingColList: [
  205. { label: '原厂编码', value: 'productOrigCode' },
  206. { label: '品牌', value: 'brandName' },
  207. { label: '仓库', value: 'warehouseName' },
  208. { label: '仓位', value: 'warehouseLocationName' },
  209. { label: '库存数量', value: 'currentQty' },
  210. { label: '单位', value: 'unit' },
  211. { label: '成本价', value: 'putCost' },
  212. { label: '市级价', value: 'dealerProduct.cityPrice' }
  213. ],
  214. productType: [],
  215. queryParam: { // 查询条件
  216. customerSn: '',
  217. salePriceType: '',
  218. productCode: '', // 产品编码
  219. productName: '', // 产品名称
  220. productOrigCode: '', // 原厂编码
  221. vinNo: '',
  222. productCodeList: undefined, // 车架号
  223. brandSn: undefined, // 产品品牌
  224. productTypeSn1: '', // 产品一级分类
  225. productTypeSn2: '', // 产品二级分类
  226. productTypeSn3: '', // 产品三级分类
  227. warehouseSn: undefined // 仓库
  228. },
  229. rules: {
  230. vinNo: [ { len: 17, message: '请输入正确的车架号(VIN)', trigger: 'change' } ]
  231. },
  232. disabled: false, // 查询、重置按钮是否可操作
  233. productBrandList: [], // 下拉数据
  234. productTypeList: [], // 产品分类 下拉数据
  235. warehouseList: [], // 仓库列表
  236. columnsBak: [
  237. { title: '产品编码', dataIndex: 'productCode', width: 150, align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
  238. { title: '产品名称', dataIndex: 'productName', align: 'center', customRender: function (text) { return text || '--' } },
  239. { title: '原厂编码', dataIndex: 'productOrigCode', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
  240. { title: '品牌', dataIndex: 'brandName', width: 100, align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
  241. { title: '仓库', dataIndex: 'warehouseName', width: 100, align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
  242. { title: '仓位', dataIndex: 'warehouseLocationName', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  243. { title: '库存数量', dataIndex: 'currentQty', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  244. { title: '单位', dataIndex: 'unit', width: 60, align: 'center', customRender: function (text) { return text || '--' } },
  245. { title: '成本价', dataIndex: 'putCost', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  246. { title: '市级价', dataIndex: 'dealerProduct.cityPrice', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  247. { title: '售价', dataIndex: 'salePrice', scopedSlots: { customRender: 'salePrice' }, width: 100, align: 'center' },
  248. { title: '销售数量', dataIndex: 'salesNums', scopedSlots: { customRender: 'nums' }, width: 100, align: 'center' },
  249. { title: '操作', dataIndex: 'action', scopedSlots: { customRender: 'action' }, width: 150, align: 'center', fixed: 'right' }
  250. ],
  251. columns: [],
  252. // 加载数据方法 必须为 Promise 对象
  253. loadData: parameter => {
  254. this.disabled = true
  255. this.queryParam.salePriceType = this.priceType
  256. this.queryParam.customerSn = this.buyerSn
  257. // 排序
  258. if (parameter.sortField == 'productCode') {
  259. parameter.sortField = 'code'
  260. parameter.sortAlias = 'product '
  261. }
  262. if (parameter.sortField == 'brandName') {
  263. parameter.sortField = 'firstChar'
  264. parameter.sortAlias = 'brand'
  265. }
  266. if (parameter.sortField == 'warehouseName') {
  267. parameter.sortField = 'warehouseSn'
  268. parameter.sortAlias = 'sd'
  269. }
  270. return querySumByProductLocation(Object.assign(parameter, this.queryParam)).then(res => {
  271. const data = res.data
  272. data.list = data.list.filter(item => item != null)
  273. const no = (data.pageNo - 1) * data.pageSize
  274. for (var i = 0; i < data.list.length; i++) {
  275. data.list[i].no = no + i + 1
  276. data.list[i].salesNums = 1
  277. data.list[i].currentQty = data.list[i].currentQty || 0
  278. }
  279. this.disabled = false
  280. return data
  281. })
  282. },
  283. openModal: false // 查看客户详情 弹框
  284. }
  285. },
  286. created () {
  287. this.columns = this.columnsBak
  288. this.onSettingChange()
  289. // 产品品牌
  290. if (this.productBrandList.length == 0) {
  291. this.getProductBrand()
  292. }
  293. // 产品分类
  294. if (this.productTypeList.length == 0) {
  295. this.getProductType()
  296. }
  297. // 仓库
  298. if (this.warehouseList.length == 0) {
  299. this.getWarehouse()
  300. }
  301. },
  302. methods: {
  303. // vin change
  304. vinNoChange (e) {
  305. if (e.target.value.length == 17) {
  306. supperCodeByVin({ vin: e.target.value }).then(res => {
  307. if (res.status == 200) {
  308. this.queryParam.productCodeList = res.data
  309. } else {
  310. this.queryParam.productCodeList = undefined
  311. }
  312. })
  313. } else {
  314. this.queryParam.productCodeList = undefined
  315. }
  316. },
  317. // 设置列
  318. onSettingChange (v) {
  319. const k = ['productOrigCode', 'brandName', 'warehouseName', 'warehouseLocationName', 'currentQty', 'unit', 'putCost', 'dealerProduct.cityPrice']
  320. const a = ['productCode', 'productName']
  321. const b = ['salePrice', 'salesNums', 'action']
  322. const c = this.settingColVal
  323. const q = k.filter(item => c.indexOf(item) >= 0)
  324. const o = a.concat(q).concat(b) // 列
  325. const r = q.concat(b) // 计算表格宽度
  326. const d = []
  327. let w = 0
  328. for (let i = 0; i < o.length; i++) {
  329. const row = this.columnsBak.find(item => item.dataIndex == o[i])
  330. if (row) {
  331. d.push(row)
  332. }
  333. }
  334. for (let i = 0; i < r.length; i++) {
  335. const row = this.columnsBak.find(item => item.dataIndex == r[i])
  336. if (row) {
  337. w = w + row.width
  338. }
  339. }
  340. this.tableWidth = w + 350
  341. this.columns = d
  342. },
  343. // 双击列表
  344. handleClickRow (record) {
  345. const _this = this
  346. return {
  347. on: {
  348. dblclick: (event) => {
  349. event.stopPropagation()
  350. _this.$emit('add', record)
  351. }
  352. }
  353. }
  354. },
  355. // 重置
  356. resetSearchForm () {
  357. this.queryParam.productCode = ''
  358. this.queryParam.productName = ''
  359. this.queryParam.productOrigCode = ''
  360. this.queryParam.brandSn = undefined
  361. this.queryParam.productTypeSn1 = ''
  362. this.queryParam.productTypeSn2 = ''
  363. this.queryParam.productTypeSn3 = ''
  364. this.queryParam.warehouseSn = undefined
  365. this.queryParam.productCodeList = undefined
  366. this.queryParam.vinNo = ''
  367. this.productType = []
  368. this.$refs.table.refresh(true)
  369. this.$refs.ruleForm.resetFields()
  370. },
  371. // 刷新当前页面
  372. resetCurForm () {
  373. this.$refs.table.refresh()
  374. },
  375. filterOption (input, option) {
  376. return (
  377. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  378. )
  379. },
  380. // 选择配件
  381. handleAdd (row) {
  382. this.$emit('add', row)
  383. },
  384. // 销售记录
  385. handleDetail (row) {
  386. this.openModal = true
  387. this.$refs.salseRecord.getDetail(this.buyerSn, row.productSn)
  388. },
  389. // 关闭弹框
  390. closeModal () {
  391. this.openModal = false
  392. },
  393. // 仓库
  394. getWarehouse () {
  395. warehouseAllList({}).then(res => {
  396. if (res.status == 200) {
  397. this.warehouseList = res.data
  398. } else {
  399. this.warehouseList = []
  400. }
  401. })
  402. },
  403. // 产品品牌 列表
  404. getProductBrand () {
  405. dealerProductBrandQuery({ sysFlag: 0 }).then(res => {
  406. if (res.status == 200) {
  407. this.productBrandList = res.data
  408. } else {
  409. this.productBrandList = []
  410. }
  411. })
  412. },
  413. // 产品分类 列表
  414. getProductType () {
  415. dealerProductTypeList({}).then(res => {
  416. if (res.status == 200) {
  417. this.productTypeList = res.data
  418. } else {
  419. this.productTypeList = []
  420. }
  421. })
  422. },
  423. // 产品分类 change
  424. changeProductType (val, opt) {
  425. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  426. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  427. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  428. }
  429. }
  430. }
  431. </script>