queryPart.vue 11 KB

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