spList.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <template>
  2. <a-spin :spinning="spinning" tip="Loading...">
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form-model
  6. id="vinAnaly-form"
  7. ref="ruleForm"
  8. class="form-model-con"
  9. layout="inline"
  10. :model="queryParam"
  11. :rules="rules"
  12. :labelCol="labelCol"
  13. :wrapperCol="wrapperCol"
  14. @keyup.enter.native="handleSearch" >
  15. <a-row :gutter="15">
  16. <a-col :md="5" :sm="24">
  17. <a-form-model-item label="货架名称" prop="shelfSn">
  18. <shelfSList v-model="queryParam.shelfSn" @change="shelfChange"></shelfSList>
  19. </a-form-model-item>
  20. </a-col>
  21. <a-col :md="4" :sm="24">
  22. <a-form-model-item label="产品编码">
  23. <a-input id="vinAnaly-VIN" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码"/>
  24. </a-form-model-item>
  25. </a-col>
  26. <a-col :md="4" :sm="24">
  27. <a-form-model-item label="产品名称">
  28. <a-input id="vinAnaly-VIN" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
  29. </a-form-model-item>
  30. </a-col>
  31. <a-col :md="4" :sm="24">
  32. <a-form-model-item label="原厂编码">
  33. <a-input id="vinAnaly-VIN" v-model.trim="queryParam.origCode" allowClear placeholder="请输入原厂编码"/>
  34. </a-form-model-item>
  35. </a-col>
  36. <template v-if="advanced">
  37. <a-col :md="5" :sm="24">
  38. <a-form-item label="产品品牌">
  39. <ProductBrand placeholder="请选择产品品牌" v-model="queryParam.brandSn"></ProductBrand>
  40. </a-form-item>
  41. </a-col>
  42. <a-col :md="5" :sm="24">
  43. <a-form-item label="产品分类">
  44. <ProductType placeholder="请选择产品分类" :isDealer="true" @change="changeProductType" v-model="productType"></ProductType>
  45. </a-form-item>
  46. </a-col>
  47. <a-col :md="6" :sm="24">
  48. <a-form-model-item label="VIN扫描时间">
  49. <rangeDate ref="scanDate" v-model="time" @change="dateChange" />
  50. </a-form-model-item>
  51. </a-col>
  52. </template>
  53. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  54. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="vinAnaly-refresh">查询</a-button>
  55. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="vinAnaly-reset">重置</a-button>
  56. <a-button
  57. type="primary"
  58. style="margin-left: 5px"
  59. @click="handleExport"
  60. :disabled="disabled"
  61. :loading="exportLoading"
  62. class="button-warning"
  63. id="vinAnaly-export-btn">导出</a-button>
  64. <a @click="advanced=!advanced" style="margin-left: 5px">
  65. {{ advanced ? '收起' : '展开' }}
  66. <a-icon :type="advanced ? 'up' : 'down'"/>
  67. </a>
  68. </a-col>
  69. </a-row>
  70. </a-form-model>
  71. </div>
  72. <div v-show="isSearchFlag">
  73. <div class="t-title" style="display: flex;align-items: center;justify-content: space-between;padding:5px 0;">
  74. <div style="border-left:2px solid #eee;padding:0 5px;font-weight: bold;font-size:14px;">{{ shelfName||'' }}</div>
  75. <div></div>
  76. </div>
  77. <!-- 列表 -->
  78. <s-table
  79. class="sTable"
  80. ref="table"
  81. size="small"
  82. :rowKey="(record) => record.productSn"
  83. rowKeyName="productSn"
  84. :columns="columns"
  85. :data="loadData"
  86. :defaultLoadData="false"
  87. bordered>
  88. <template slot="type" slot-scope="text, record">
  89. <div>
  90. {{ record.productTypeName2 }}->{{ record.productTypeName3 }}
  91. </div>
  92. </template>
  93. </s-table>
  94. </div>
  95. <div class="unChoose" v-show="!isSearchFlag">
  96. <a-icon type="exclamation-circle" :style="{ fontSize: '18px', color: '#ff9900', verticalAlign: 'sub', marginRight: '5px' }" />
  97. <span>请选择一个货架后点击查询按钮</span>
  98. </div>
  99. </div>
  100. </a-spin>
  101. </template>
  102. <script>
  103. import { commonMixin } from '@/utils/mixin'
  104. import { STable, VSelect } from '@/components'
  105. import rangeDate from '@/views/common/rangeDate.vue'
  106. import { downloadExcel } from '@/libs/JGPrint.js'
  107. import shelfSList from '@/views/common/shelfList'
  108. import ProductType from '../../common/productType.js'
  109. import ProductBrand from '../../common/productBrand.js'
  110. import { reportPage, exportReport } from '@/api/vinLog'
  111. export default {
  112. components: { STable, VSelect, rangeDate, shelfSList, ProductType, ProductBrand },
  113. mixins: [commonMixin],
  114. data () {
  115. return {
  116. spinning: false,
  117. labelCol: { span: 8 },
  118. wrapperCol: { span: 16 },
  119. advanced: true, // 高级搜索 展开/关闭
  120. tableHeight: 0,
  121. productType: [],
  122. queryParam: { // 查询条件
  123. beginDate: '',
  124. endDate: '',
  125. shelfSn: undefined,
  126. productCode: undefined, // 产品编码
  127. productName: undefined, // 产品名称
  128. origCode: undefined, // 原厂编码
  129. brandSn: undefined, // 产品品牌
  130. productTypeSn1: undefined, // 产品一级分类
  131. productTypeSn2: undefined, // 产品二级分类
  132. productTypeSn3: undefined // 产品三级分类
  133. },
  134. isSearchFlag: false,
  135. time: [],
  136. rules: {
  137. 'shelfSn': [{ required: true, message: '请选择货架', trigger: 'change' }]
  138. },
  139. disabled: false, // 查询、重置按钮是否可操作
  140. exportLoading: false,
  141. order_by: '',
  142. // 加载数据方法 必须为 Promise 对象
  143. loadData: parameter => {
  144. this.spinning = true
  145. this.disabled = true
  146. const newParameter = parameter
  147. if (newParameter.sortField && newParameter.sortField == 'inStockCount') { // 有货
  148. if (newParameter.sortOrder) {
  149. if (newParameter.sortOrder != 'ascend') { // 降序
  150. newParameter.orderBy = 'xvfp.in_stock_count desc,xp.code asc'
  151. } else {
  152. newParameter.orderBy = 'xvfp.in_stock_count asc,xp.code asc'
  153. }
  154. this.order_by = newParameter.orderBy
  155. } else {
  156. this.order_by = ''
  157. }
  158. }
  159. if (newParameter.sortField && newParameter.sortField == 'notStockCount') { // 无货
  160. if (newParameter.sortOrder) {
  161. if (newParameter.sortOrder != 'ascend') { // 降序
  162. newParameter.orderBy = 'xvfp.not_stock_count desc,xp.code asc'
  163. } else {
  164. newParameter.orderBy = 'xvfp.not_stock_count asc,xp.code asc'
  165. }
  166. this.order_by = newParameter.orderBy
  167. } else {
  168. this.order_by = ''
  169. }
  170. }
  171. const params = Object.assign(newParameter, this.queryParam, { orderBy: this.order_by })
  172. delete params.time
  173. return reportPage(params).then(res => {
  174. let data
  175. if (res.status == 200) {
  176. data = res.data
  177. const no = (data.pageNo - 1) * data.pageSize
  178. for (var i = 0; i < data.list.length; i++) {
  179. data.list[i].no = no + i + 1
  180. }
  181. this.disabled = false
  182. }
  183. this.spinning = false
  184. return data
  185. })
  186. },
  187. shelfName: '',
  188. filters: [{ text: '有', value: '1' }, { text: '无', value: '0' }, { text: '空(--)', value: '' }]
  189. }
  190. },
  191. computed: {
  192. columns () {
  193. const arr = [
  194. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  195. { title: '产品编码', dataIndex: 'productCode', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  196. { title: '产品名称', dataIndex: 'productName', width: '12%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  197. { title: '原厂编码', dataIndex: 'origCode', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  198. { title: '产品品牌', dataIndex: 'brandName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  199. { title: '产品分类', slots: { title: 'type' }, scopedSlots: { customRender: 'type' }, width: '10%', align: 'center' },
  200. { title: '适配有货次数', dataIndex: 'inStockCount', width: '10%', align: 'center', customRender: function (text) { return (text || text == 0) ? text : '--' }, sorter: (a, b) => a.inStockCount - b.inStockCount },
  201. { title: '适配缺货次数', dataIndex: 'notStockCount', width: '10%', align: 'center', customRender: function (text) { return (text || text == 0) ? text : '--' }, sorter: (a, b) => a.notStockCount - b.notStockCount }
  202. // { title: '最近VIN扫描时间', dataIndex: 'scanVinDate', width: '7%', align: 'center', customRender: function (text) { return text || '--' }, sorter: true }
  203. ]
  204. return arr
  205. }
  206. },
  207. methods: {
  208. shelfChange (v, row) {
  209. this.shelfName = row ? row.shelfName : ''
  210. },
  211. // 产品分类 change
  212. changeProductType (val, opt) {
  213. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  214. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  215. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  216. },
  217. // 创建时间 change
  218. dateChange (date) {
  219. this.time = date
  220. this.queryParam.beginDate = date[0]
  221. this.queryParam.endDate = date[1]
  222. },
  223. // 查询
  224. handleSearch () {
  225. this.$refs.ruleForm.validate(valid => {
  226. if (valid) {
  227. this.isSearchFlag = true
  228. this.$refs.table.refresh(true)
  229. } else {
  230. console.log('error submit!!')
  231. return false
  232. }
  233. })
  234. },
  235. // 重置
  236. resetSearchForm () {
  237. this.isSearchFlag = false
  238. this.queryParam = {
  239. beginDate: '',
  240. endDate: '',
  241. shelfSn: undefined,
  242. productCode: undefined, // 产品编码
  243. productName: undefined, // 产品名称
  244. origCode: undefined, // 原厂编码
  245. brandSn: undefined, // 产品品牌
  246. productTypeSn1: undefined, // 产品一级分类
  247. productTypeSn2: undefined, // 产品二级分类
  248. productTypeSn3: undefined // 产品三级分类
  249. }
  250. this.time = []
  251. this.productType = []
  252. this.$refs.ruleForm.resetFields()
  253. this.$refs.table.clearTable()
  254. if (this.advanced) {
  255. this.$refs.scanDate.resetDate()
  256. }
  257. this.handleSearch()
  258. },
  259. // 导出
  260. handleExport () {
  261. const _this = this
  262. this.$refs.ruleForm.validate(valid => {
  263. if (valid) {
  264. const params = _this.queryParam
  265. params.orderBy = this.order_by
  266. _this.exportLoading = true
  267. _this.spinning = true
  268. exportReport(params).then(res => {
  269. downloadExcel(res, '适配产品统计')
  270. _this.exportLoading = false
  271. _this.spinning = false
  272. })
  273. } else {
  274. console.log('error submit!!')
  275. return false
  276. }
  277. })
  278. },
  279. filterOption (input, option) {
  280. return (
  281. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  282. )
  283. },
  284. handleDetail (row) {
  285. this.curItem = row
  286. this.showDetail = true
  287. }
  288. },
  289. mounted () {
  290. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  291. this.resetSearchForm()
  292. }
  293. },
  294. activated () {
  295. // 如果是新页签打开,则重置当前页面
  296. if (this.$store.state.app.isNewTab) {
  297. this.resetSearchForm()
  298. }
  299. },
  300. beforeRouteEnter (to, from, next) {
  301. next(vm => {})
  302. }
  303. }
  304. </script>
  305. <style lang="less" scoped>
  306. .unChoose {
  307. text-align: center;
  308. margin: 280px 0 340px;
  309. font-size: 16px;
  310. }
  311. </style>