queryPart.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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" :disabled="disabled" 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-icon style="margin:0 15px" type="setting" theme="twoTone" />
  87. </a-col>
  88. </a-row>
  89. </a-form>
  90. </div>
  91. <!-- 列表 -->
  92. <s-table
  93. class="sTable"
  94. ref="table"
  95. size="default"
  96. :rowKey="(record) => record.id"
  97. :columns="columns"
  98. :data="loadData"
  99. :customRow="handleClickRow"
  100. :scroll="{ x: 1530, y: 150 }"
  101. :pageSize="30"
  102. bordered>
  103. <!-- 售价 -->
  104. <template slot="price" slot-scope="text, record">
  105. <div @dblclick.stop>
  106. <a-input-number
  107. v-model="record.dealerProduct.cityPrice"
  108. :precision="2"
  109. :min="0"
  110. :max="999999"
  111. placeholder="请输入" />
  112. </div>
  113. </template>
  114. <!-- 销售数量 -->
  115. <template slot="nums" slot-scope="text, record">
  116. <div @dblclick.stop>
  117. <a-input-number
  118. v-model="record.salesNums"
  119. :precision="0"
  120. :min="0"
  121. :max="999999"
  122. placeholder="请输入" />
  123. </div>
  124. </template>
  125. <!-- 操作 -->
  126. <template slot="action" slot-scope="text, record">
  127. <a-button size="small" type="primary" class="button-info" @click="handleAdd(record)" id="productInfoList-edit-btn">添加</a-button>
  128. <a-button
  129. size="small"
  130. type="primary"
  131. class="button-success"
  132. @click="handleDetail(record)"
  133. id="productInfoList-detail-btn"
  134. style="margin-left: 15px;">销售记录</a-button>
  135. </template>
  136. </s-table>
  137. <!-- 销售记录 -->
  138. <product-salesRecord-modal ref="salseRecord" :openModal="openModal" @close="closeModal" />
  139. </div>
  140. </template>
  141. <script>
  142. import { productBrandQuery } from '@/api/productBrand'
  143. import { productTypeQuery } from '@/api/productType'
  144. import { querySumByProductLocation } from '@/api/stock'
  145. import { warehouseAllList } from '@/api/warehouse'
  146. import productSalesRecordModal from './productSalesRecordModal.vue'
  147. import { STable, VSelect } from '@/components'
  148. export default {
  149. name: 'QueryPart',
  150. components: { STable, VSelect, productSalesRecordModal },
  151. props: {
  152. buyerSn: {
  153. type: [Number, String],
  154. default: ''
  155. }
  156. },
  157. data () {
  158. return {
  159. advanced: false, // 高级搜索 展开/关闭
  160. productType: [],
  161. queryParam: { // 查询条件
  162. productCode: '', // 产品编码
  163. productName: '', // 产品名称
  164. productOrigCode: '', // 原厂编码
  165. brandSn: undefined, // 产品品牌
  166. productTypeSn1: '', // 产品一级分类
  167. productTypeSn2: '', // 产品二级分类
  168. productTypeSn3: '', // 产品三级分类
  169. warehouseSn: undefined // 仓库
  170. },
  171. disabled: false, // 查询、重置按钮是否可操作
  172. exportLoading: false, // 导出loading
  173. productBrandList: [], // 下拉数据
  174. productTypeList: [], // 产品类别 下拉数据
  175. warehouseList: [], // 仓库列表
  176. columns: [
  177. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  178. { title: '产品编码', dataIndex: 'productCode', width: 140, align: 'center', sorter: true },
  179. { title: '产品名称', dataIndex: 'productName', align: 'center' },
  180. { title: '原厂编码', dataIndex: 'productOrigCode', width: 140, align: 'center' },
  181. { title: '品牌', dataIndex: 'brandName', width: 100, align: 'center', sorter: true },
  182. { title: '仓库', dataIndex: 'warehouseName', width: 100, align: 'center', sorter: true },
  183. { title: '仓位', dataIndex: 'warehouseLocationName', width: 100, align: 'center' },
  184. { title: '售价', scopedSlots: { customRender: 'price' }, width: 150, align: 'center' },
  185. { title: '销售数量', scopedSlots: { customRender: 'nums' }, width: 150, align: 'center' },
  186. { title: '单位', dataIndex: 'unit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  187. { title: '操作', scopedSlots: { customRender: 'action' }, width: 200, align: 'center', fixed: 'right' }
  188. ],
  189. // 加载数据方法 必须为 Promise 对象
  190. loadData: parameter => {
  191. this.disabled = true
  192. return querySumByProductLocation(Object.assign(parameter, this.queryParam)).then(res => {
  193. const data = res.data
  194. const no = (data.pageNo - 1) * data.pageSize
  195. for (var i = 0; i < data.list.length; i++) {
  196. data.list[i].no = no + i + 1
  197. data.list[i].salesNums = 1
  198. }
  199. this.disabled = false
  200. // 产品品牌
  201. if (this.productBrandList.length == 0) {
  202. this.getProductBrand()
  203. }
  204. // 产品分类
  205. if (this.productTypeList.length == 0) {
  206. this.getProductType()
  207. }
  208. // 仓库
  209. if (this.warehouseList.length == 0) {
  210. this.getWarehouse()
  211. }
  212. return data
  213. })
  214. },
  215. openModal: false // 查看客户详情 弹框
  216. }
  217. },
  218. methods: {
  219. // 双击列表
  220. handleClickRow (record) {
  221. const _this = this
  222. return {
  223. on: {
  224. dblclick: (event) => {
  225. event.stopPropagation()
  226. _this.$emit('add', record)
  227. }
  228. }
  229. }
  230. },
  231. // 重置
  232. resetSearchForm () {
  233. this.queryParam.productName = ''
  234. this.queryParam.productOrigCode = ''
  235. this.queryParam.brandSn = undefined
  236. this.queryParam.productTypeSn1 = ''
  237. this.queryParam.productTypeSn2 = ''
  238. this.queryParam.productTypeSn3 = ''
  239. this.queryParam.warehouseSn = undefined
  240. this.productType = []
  241. this.$refs.table.refresh(true)
  242. },
  243. filterOption (input, option) {
  244. return (
  245. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  246. )
  247. },
  248. // 选择配件
  249. handleAdd (row) {
  250. this.$emit('add', row)
  251. },
  252. // 销售记录
  253. handleDetail (row) {
  254. this.openModal = true
  255. this.$refs.salseRecord.getDetail(this.buyerSn, row.productSn)
  256. },
  257. // 关闭弹框
  258. closeModal () {
  259. this.openModal = false
  260. },
  261. // 仓库
  262. getWarehouse () {
  263. warehouseAllList({}).then(res => {
  264. if (res.status == 200) {
  265. this.warehouseList = res.data
  266. } else {
  267. this.warehouseList = []
  268. }
  269. })
  270. },
  271. // 产品品牌 列表
  272. getProductBrand () {
  273. productBrandQuery({}).then(res => {
  274. if (res.status == 200) {
  275. this.productBrandList = res.data
  276. } else {
  277. this.productBrandList = []
  278. }
  279. })
  280. },
  281. // 产品分类 列表
  282. getProductType () {
  283. productTypeQuery({}).then(res => {
  284. if (res.status == 200) {
  285. this.productTypeList = res.data
  286. } else {
  287. this.productTypeList = []
  288. }
  289. })
  290. },
  291. // 产品分类 change
  292. changeProductType (val, opt) {
  293. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  294. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  295. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  296. }
  297. }
  298. }
  299. </script>