vinList.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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="shelfSn">
  18. <shelfSList v-model="queryParam.shelfSn" @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="6" :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="6" :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="6" :sm="24">
  38. <a-form-model-item label="车型">
  39. <a-input id="vinAnaly-salesManName" v-model.trim="queryParam.modelInfo" 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. <div 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. </div>
  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. shelfSn: undefined,
  135. brandName: undefined,
  136. modelInfo: undefined
  137. },
  138. airConditionerFilterData: null,
  139. airFilterFlagData: null,
  140. engineOilFilterFlagData: null,
  141. isSearch: false,
  142. time: [],
  143. rules: {
  144. 'shelfSn': [{ required: true, message: '请选择货架', trigger: 'change' }]
  145. },
  146. disabled: false, // 查询、重置按钮是否可操作
  147. exportLoading: false,
  148. // 加载数据方法 必须为 Promise 对象
  149. loadData: (parameter) => {
  150. const dataObj = parameter
  151. if (dataObj.airConditionerFilterFlagDesc) {
  152. dataObj.airConditionerFilterFlag = dataObj.airConditionerFilterFlagDesc.toString()
  153. this.airConditionerFilterData = dataObj.airConditionerFilterFlagDesc.toString()
  154. delete dataObj.airConditionerFilterFlagDesc
  155. }
  156. if (dataObj.airFilterFlagDesc) {
  157. dataObj.airFilterFlag = dataObj.airFilterFlagDesc.toString()
  158. this.airFilterFlagData = dataObj.airFilterFlagDesc.toString()
  159. delete dataObj.airFilterFlagDesc
  160. }
  161. if (dataObj.engineOilFilterFlagDesc) {
  162. dataObj.engineOilFilterFlag = dataObj.engineOilFilterFlagDesc.toString()
  163. this.engineOilFilterFlagData = dataObj.engineOilFilterFlagDesc.toString()
  164. delete dataObj.engineOilFilterFlagDesc
  165. }
  166. this.disabled = true
  167. const params = Object.assign(dataObj, this.queryParam, { airConditionerFilterFlag: this.airConditionerFilterData,
  168. airFilterFlag: this.airFilterFlagData,
  169. engineOilFilterFlag: this.engineOilFilterFlagData })
  170. this.spinning = true
  171. return queryPage(params).then(res => {
  172. let data
  173. if (res.status == 200) {
  174. data = res.data
  175. const no = (data.pageNo - 1) * data.pageSize
  176. for (var i = 0; i < data.list.length; i++) {
  177. data.list[i].no = no + i + 1
  178. }
  179. }
  180. this.getQueryCount(params)
  181. this.spinning = false
  182. return data
  183. })
  184. },
  185. queryCountData: null,
  186. shelfName: '',
  187. showColItem: [
  188. { label: '空调滤清器', value: 'kt' },
  189. { label: '空气滤清器', value: 'kq' },
  190. { label: '机油滤清器', value: 'jy' }
  191. ],
  192. showCol: ['kt', 'kq', 'jy'],
  193. filters: [{ text: '有', value: 1 }, { text: '无', value: 2 }, { text: '空(--)', value: 0 }],
  194. showDetail: false,
  195. curItem: null
  196. }
  197. },
  198. computed: {
  199. columns () {
  200. const arr = [
  201. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  202. { title: '扫描时间', dataIndex: 'createDate', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  203. // { title: 'VIN', dataIndex: 'vinCode', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  204. { title: 'VIN', scopedSlots: { customRender: 'vin' }, width: '15%', align: 'center' },
  205. { title: '车辆品牌', dataIndex: 'brandName', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  206. { title: '车型', dataIndex: 'modelInfo', width: '24%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true }
  207. ]
  208. this.showCol.map(item => {
  209. if (item == 'kt') {
  210. arr.push({ title: '空调滤清器适配', dataIndex: 'airConditionerFilterFlagDesc', filters: this.filters, filterMultiple: false, width: '120px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  211. }
  212. if (item == 'kq') {
  213. arr.push({ title: '空气滤清器适配', dataIndex: 'airFilterFlagDesc', filters: this.filters, filterMultiple: false, width: '120px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  214. }
  215. if (item == 'jy') {
  216. arr.push({ title: '机油滤清器适配', dataIndex: 'engineOilFilterFlagDesc', filters: this.filters, filterMultiple: false, width: '120px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  217. }
  218. })
  219. return arr
  220. }
  221. },
  222. methods: {
  223. shelfChange (v, row) {
  224. this.shelfName = row ? row.shelfName : ''
  225. },
  226. // 累积扫描VIN次数统计
  227. getQueryCount (ajaxData) {
  228. queryCount(ajaxData).then(res => {
  229. if (res.status == 200) {
  230. this.queryCountData = res.data
  231. } else {
  232. this.queryCountData = null
  233. }
  234. })
  235. },
  236. // 扫描时间 change
  237. dateChange (date) {
  238. this.time = date
  239. this.queryParam.beginDate = date[0] || ''
  240. this.queryParam.endDate = date[1] || ''
  241. },
  242. // 查询
  243. handleSearch () {
  244. this.$refs.ruleForm.validate(valid => {
  245. if (valid) {
  246. this.$refs.table.refresh(true)
  247. this.isSearch = true
  248. } else {
  249. console.log('error submit!!')
  250. return false
  251. }
  252. })
  253. },
  254. // 重置
  255. resetSearchForm () {
  256. this.isSearch = false
  257. this.queryParam.beginDate = ''
  258. this.queryParam.endDate = ''
  259. this.queryParam.vinCode = undefined
  260. this.queryParam.shelfSn = undefined
  261. this.queryParam.brandName = undefined
  262. this.queryParam.modelInfo = undefined
  263. this.time = []
  264. this.$refs.rangeDate.resetDate(this.time)
  265. this.$refs.ruleForm.resetFields()
  266. // this.$refs.table.refresh(true)
  267. this.handleSearch()
  268. },
  269. // 导出
  270. handleExport () {
  271. const _this = this
  272. this.$refs.ruleForm.validate(valid => {
  273. if (valid) {
  274. const newFilterObj = {
  275. exportAirConditionerFilterFlag: this.showCol.includes('kt') ? 1 : 0,
  276. exportAirFilterFlag: this.showCol.includes('kq') ? 1 : 0,
  277. exportEngineOilFilterFlag: this.showCol.includes('jy') ? 1 : 0,
  278. airConditionerFilterFlag: this.airConditionerFilterData,
  279. airFilterFlag: this.airFilterFlagData,
  280. engineOilFilterFlag: this.engineOilFilterFlagData
  281. }
  282. const params = Object.assign(this.queryParam, newFilterObj)
  283. _this.exportLoading = true
  284. _this.spinning = true
  285. exportVinLog(params).then(res => {
  286. downloadExcel(res, 'VIN扫描记录')
  287. _this.exportLoading = false
  288. _this.spinning = false
  289. })
  290. } else {
  291. console.log('error submit!!')
  292. return false
  293. }
  294. })
  295. },
  296. handleDetail (row) {
  297. queryDetail({ id: row.id }).then(res => {
  298. if (res.status == 200) {
  299. const detailObj = {
  300. vinCode: row.vinCode,
  301. scanTime: row.createDate,
  302. carType: row.modelInfo
  303. }
  304. Object.assign(res.data, detailObj)
  305. this.curItem = res.data
  306. this.showDetail = true
  307. }
  308. })
  309. }
  310. },
  311. mounted () {
  312. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  313. this.resetSearchForm()
  314. }
  315. },
  316. activated () {
  317. // 如果是新页签打开,则重置当前页面
  318. if (this.$store.state.app.isNewTab) {
  319. this.resetSearchForm()
  320. }
  321. },
  322. beforeRouteEnter (to, from, next) {
  323. next(vm => {})
  324. }
  325. }
  326. </script>
  327. <style lang="less" scoped>
  328. .unChoose {
  329. text-align: center;
  330. margin: 280px 0 340px;
  331. font-size: 16px;
  332. }
  333. .sTable{
  334. min-width:1004px;
  335. }
  336. </style>