vinList.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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="6" :sm="24">
  17. <a-form-model-item label="货架名称" prop="shelf_sn">
  18. <shelfSList v-model="queryParam.shelf_sn" @change="shelfChange"></shelfSList>
  19. </a-form-model-item>
  20. </a-col>
  21. <a-col :md="6" :sm="24">
  22. <a-form-model-item label="扫描时间">
  23. <rangeDate ref="rangeDate" v-model="time" @change="dateChange" />
  24. </a-form-model-item>
  25. </a-col>
  26. <template v-if="advanced">
  27. <a-col :md="4" :sm="24">
  28. <a-form-model-item label="VIN">
  29. <a-input id="vinAnaly-VIN" v-model.trim="queryParam.vinCode" allowClear placeholder="请输入VIN"/>
  30. </a-form-model-item>
  31. </a-col>
  32. <a-col :md="4" :sm="24">
  33. <a-form-model-item label="车辆品牌">
  34. <a-input id="vinAnaly-salesBillNo" v-model.trim="queryParam.brandName" allowClear placeholder="请输入车辆品牌"/>
  35. </a-form-model-item>
  36. </a-col>
  37. <a-col :md="4" :sm="24">
  38. <a-form-model-item label="车型">
  39. <a-input id="vinAnaly-salesManName" v-model.trim="queryParam.modelName" allowClear placeholder="请输入车型"/>
  40. </a-form-model-item>
  41. </a-col>
  42. </template>
  43. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  44. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="vinAnaly-refresh">查询</a-button>
  45. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="vinAnaly-reset">重置</a-button>
  46. <a-button
  47. type="primary"
  48. style="margin-left: 5px"
  49. @click="handleExport"
  50. :disabled="disabled"
  51. :loading="exportLoading"
  52. class="button-warning"
  53. id="vinAnaly-export-btn">导出</a-button>
  54. <a @click="advanced=!advanced" style="margin-left: 5px">
  55. {{ advanced ? '收起' : '展开' }}
  56. <a-icon :type="advanced ? 'up' : 'down'"/>
  57. </a>
  58. </a-col>
  59. </a-row>
  60. </a-form-model>
  61. </div>
  62. <duv v-show="isSearch">
  63. <!-- 合计 -->
  64. <a-alert type="info" style="margin-bottom:10px" v-if="queryCountData">
  65. <div class="ftext" slot="message">
  66. <div>
  67. 累计扫描VIN:<strong>{{ queryCountData.scanCount }}</strong>次;
  68. </div>
  69. <div>
  70. 空调滤清器 有适配:<strong>{{ queryCountData.airConditionerFilterOnShelfCount }}</strong>次,<strong>{{ queryCountData.airConditionerFilterOnShelfRate }}</strong>;无适配:<strong>{{ queryCountData.airConditionerFilterOffShelfCount }}</strong>次,<strong>{{ queryCountData.airConditionerFilterOffShelfRate }}</strong>;空(--):<strong>{{ queryCountData.airConditionerFilterNotExistCount }}</strong>次,<strong>{{ queryCountData.airConditionerFilterNotExistRate }}</strong>;
  71. </div>
  72. <div>
  73. 空气滤清器 有适配:<strong>{{ queryCountData.airFilterOnShelfCount }}</strong>次,<strong>{{ queryCountData.airFilterOnShelfRate }}</strong>;无适配:<strong>{{ queryCountData.airFilterOffShelfCount }}</strong>次,<strong>{{ queryCountData.airFilterOffShelfRate }}</strong>;空(--):<strong>{{ queryCountData.airFilterNotExistCount }}</strong>次,<strong>{{ queryCountData.airFilterNotExistRate }}</strong>;
  74. </div>
  75. <div>
  76. 机油滤清器 有适配:<strong>{{ queryCountData.engineOilFilterOnShelfCount }}</strong>次,<strong>{{ queryCountData.engineOilFilterOnShelfRate }}</strong>;无适配:<strong>{{ queryCountData.engineOilFilterOffShelfCount }}</strong>次,<strong>{{ queryCountData.engineOilFilterOffShelfRate }}</strong>;空(--):<strong>{{ queryCountData.engineOilFilterNotExistCount }}</strong>次,<strong>{{ queryCountData.engineOilFilterNotExistRate }}</strong>;
  77. </div>
  78. </div>
  79. </a-alert>
  80. <div class="t-title" style="display: flex;align-items: center;justify-content: space-between;padding:5px 0;">
  81. <div style="border-left:2px solid #eee;padding:0 5px;font-weight: bold;font-size:14px;">{{ shelfName||'' }}</div>
  82. <div>
  83. <a-checkbox-group v-model="showCol" :options="showColItem" />
  84. </div>
  85. </div>
  86. <!-- 列表 -->
  87. <s-table
  88. class="sTable"
  89. ref="table"
  90. size="small"
  91. :rowKey="(record) => record.id"
  92. :columns="columns"
  93. :data="loadData"
  94. :defaultLoadData="false"
  95. bordered>
  96. <!-- vin -->
  97. <template slot="vin" slot-scope="text, record">
  98. <div>
  99. <span class="table-td-link" @click="handleDetail(record)">{{ record.vinCode }}</span>
  100. </div>
  101. </template>
  102. </s-table>
  103. </duv>
  104. <div class="unChoose" v-show="!isSearch">
  105. <a-icon type="exclamation-circle" theme="filled" :style="{ fontSize: '18px', color: '#ff9900', verticalAlign: 'sub', marginRight: '5px' }" />
  106. <span>请选择一个货架后点击查询按钮</span>
  107. </div>
  108. <!-- 详情 -->
  109. <detailModal :openModal="showDetail" :itemData="curItem" @close="showDetail=false"></detailModal>
  110. </a-spin>
  111. </template>
  112. <script>
  113. import { commonMixin } from '@/utils/mixin'
  114. import { STable, VSelect } from '@/components'
  115. import rangeDate from '@/views/common/rangeDate.vue'
  116. import { downloadExcel } from '@/libs/JGPrint.js'
  117. import shelfSList from '@/views/common/shelfList'
  118. import detailModal from './detailModal'
  119. import { queryPage, queryCount, queryDetail, exportVinLog } from '@/api/vinLog'
  120. export default {
  121. components: { STable, VSelect, rangeDate, shelfSList, detailModal },
  122. mixins: [commonMixin],
  123. data () {
  124. return {
  125. spinning: false,
  126. labelCol: { span: 8 },
  127. wrapperCol: { span: 16 },
  128. advanced: true, // 高级搜索 展开/关闭
  129. tableHeight: 0,
  130. queryParam: { // 查询条件
  131. beginDate: '',
  132. endDate: '',
  133. vinCode: undefined,
  134. shelf_sn: undefined,
  135. brandName: undefined,
  136. modelName: undefined
  137. },
  138. isSearch: false,
  139. time: [],
  140. rules: {
  141. 'shelf_sn': [{ required: true, message: '请选择货架', trigger: 'change' }]
  142. },
  143. disabled: false, // 查询、重置按钮是否可操作
  144. exportLoading: false,
  145. // 加载数据方法 必须为 Promise 对象
  146. loadData: parameter => {
  147. this.disabled = true
  148. const params = Object.assign(parameter, this.queryParam)
  149. this.spinning = true
  150. return queryPage(params).then(res => {
  151. let data
  152. if (res.status == 200) {
  153. data = res.data
  154. const no = (data.pageNo - 1) * data.pageSize
  155. for (var i = 0; i < data.list.length; i++) {
  156. data.list[i].no = no + i + 1
  157. }
  158. }
  159. this.getQueryCount(this.queryParam)
  160. this.spinning = false
  161. return data
  162. })
  163. },
  164. queryCountData: null,
  165. shelfName: '',
  166. showColItem: [
  167. { label: '空调滤清器', value: 'kt' },
  168. { label: '空气滤清器', value: 'kq' },
  169. { label: '机油滤清器', value: 'jy' }
  170. ],
  171. showCol: ['kt', 'kq', 'jy'],
  172. filters: [{ text: '有', value: 1 }, { text: '无', value: 2 }, { text: '空(--)', value: 0 }],
  173. showDetail: false,
  174. curItem: null
  175. }
  176. },
  177. computed: {
  178. columns () {
  179. const arr = [
  180. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  181. { title: '扫描时间', dataIndex: 'createDate', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  182. // { title: 'VIN', dataIndex: 'vinCode', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  183. { title: 'VIN', scopedSlots: { customRender: 'vin' }, width: '15%', align: 'center' },
  184. { title: '车辆品牌', dataIndex: 'brandName', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  185. { title: '车型', dataIndex: 'modelName', width: '24%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true }
  186. ]
  187. this.showCol.map(item => {
  188. if (item == 'kt') {
  189. arr.push({ title: '空调滤清器适配', dataIndex: 'airConditionerFilterFlagDesc', filters: this.filters, filterMultiple: false, width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  190. }
  191. if (item == 'kq') {
  192. arr.push({ title: '空气滤清器适配', dataIndex: 'airFilterFlagDesc', filters: this.filters, filterMultiple: false, width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  193. }
  194. if (item == 'jy') {
  195. arr.push({ title: '机油滤清器适配', dataIndex: 'engineOilFilterFlagDesc', filters: this.filters, filterMultiple: false, width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  196. }
  197. })
  198. return arr
  199. }
  200. },
  201. methods: {
  202. shelfChange (v, row) {
  203. this.shelfName = row ? row.shelfName : ''
  204. },
  205. // 累积扫描VIN次数统计
  206. getQueryCount (ajaxData) {
  207. queryCount(ajaxData).then(res => {
  208. if (res.status == 200) {
  209. this.queryCountData = res.data
  210. } else {
  211. this.queryCountData = null
  212. }
  213. })
  214. },
  215. // 扫描时间 change
  216. dateChange (date) {
  217. this.time = date
  218. this.queryParam.beginDate = date[0] || ''
  219. this.queryParam.endDate = date[1] || ''
  220. },
  221. // 查询
  222. handleSearch () {
  223. this.$refs.ruleForm.validate(valid => {
  224. if (valid) {
  225. this.$refs.table.refresh(true)
  226. this.isSearch = true
  227. } else {
  228. console.log('error submit!!')
  229. return false
  230. }
  231. })
  232. },
  233. // 重置
  234. resetSearchForm () {
  235. this.isSearch = false
  236. this.queryParam.beginDate = ''
  237. this.queryParam.endDate = ''
  238. this.queryParam.vinCode = undefined
  239. this.queryParam.shelf_sn = undefined
  240. this.queryParam.brandName = undefined
  241. this.queryParam.modelName = undefined
  242. this.$refs.rangeDate.resetDate(this.time)
  243. this.$refs.ruleForm.resetFields()
  244. // this.$refs.table.refresh(true)
  245. this.handleSearch()
  246. },
  247. // 导出
  248. handleExport () {
  249. const _this = this
  250. this.$refs.ruleForm.validate(valid => {
  251. if (valid) {
  252. const params = _this.queryParam
  253. _this.exportLoading = true
  254. _this.spinning = true
  255. exportVinLog(params).then(res => {
  256. downloadExcel(res, 'VIN分析表')
  257. _this.exportLoading = false
  258. _this.spinning = false
  259. })
  260. } else {
  261. console.log('error submit!!')
  262. return false
  263. }
  264. })
  265. },
  266. handleDetail (row) {
  267. queryDetail({ id: row.id }).then(res => {
  268. if (res.status == 200) {
  269. const detailObj = {
  270. vinCode: row.vinCode,
  271. scanTime: row.createDate,
  272. carType: row.modelName
  273. }
  274. Object.assign(res.data, detailObj)
  275. this.curItem = res.data
  276. this.showDetail = true
  277. }
  278. })
  279. }
  280. },
  281. mounted () {
  282. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  283. this.resetSearchForm()
  284. }
  285. },
  286. activated () {
  287. // 如果是新页签打开,则重置当前页面
  288. if (this.$store.state.app.isNewTab) {
  289. this.resetSearchForm()
  290. }
  291. },
  292. beforeRouteEnter (to, from, next) {
  293. next(vm => {})
  294. }
  295. }
  296. </script>
  297. <style lang="less" scoped>
  298. .unChoose {
  299. text-align: center;
  300. margin: 280px 0 340px;
  301. font-size: 16px;
  302. }
  303. </style>