queryPart.vue 15 KB

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