queryPart.vue 15 KB

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