vinList.vue 11 KB

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