index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. <template>
  2. <view class="basic-data">
  3. <view class="basic-top">
  4. <view class="times">最近同步时间:{{synchronizationTime || '-'}}</view>
  5. <view class="sync-btn" @click="syncCloud">云端同步</view>
  6. <view class="title">车辆管理</view>
  7. </view>
  8. <view class="basic-search">
  9. <uni-forms ref="form" :modelValue="queryParams" class="searchForm">
  10. <uni-forms-item label="车牌号码:" label-width="72px" label-align="right" name="vehiclePlate">
  11. <uni-easyinput type="text" v-model="queryParams.vehiclePlate" placeholder="请输入车牌号码" />
  12. </uni-forms-item>
  13. <uni-forms-item label="车辆识别码:" label-width="128px" label-align="right" name="vehicleVin">
  14. <uni-easyinput type="text" v-model="queryParams.vehicleVin" placeholder="请输入车辆识别码" />
  15. </uni-forms-item>
  16. <uni-forms-item label="来源:" label-width="80px" label-align="right">
  17. <uni-data-select v-model="queryParams.source" :localdata="formSelect" style="width: 100px;"
  18. @change="change"></uni-data-select>
  19. </uni-forms-item>
  20. </uni-forms>
  21. <view class="search-btn" @click="handleQuery">查询</view>
  22. <view class="reset-btn" @click="resetForm">重置</view>
  23. </view>
  24. <view class="basic-table">
  25. <view class="search-btn marginZero" @click="OpenAddDrawer">新增</view>
  26. <baseDateTable @DelCarData="DelCarData" @EditCarData="EditCarData" :headerFixed="true"
  27. :showLoadMore="showLoadMore" :loadMore="loadMore" :columnFixed=1 :contents="datalist" :headers="headers"
  28. @onPullup="pullup">
  29. </baseDateTable>
  30. </view>
  31. <!-- 顶部公共提示信息 -->
  32. <uni-popup ref="Exchangepopup" type="message">
  33. <uni-popup-message :type="popupType" :message="popupMessage" :duration="2000"></uni-popup-message>
  34. </uni-popup>
  35. <!-- 顶部提示信息结束-->
  36. <!--右侧抽屉 -->
  37. <uni-drawer ref="BasicDrawer" mode="right" :width="400" :mask-click="true">
  38. <scroll-view style="height: 100%;" scroll-y="true">
  39. <PublicDrawer :flag="false" :title="dialogType=='new'?'新增车辆':'编辑车辆'" @closeDrawer="closeDrawer"
  40. @AddCarinfo="AddCarinfo" @EditCarInfo="EditCarInfo">
  41. <view class="drawer_main">
  42. <view>
  43. <BasicDrawer :basicFrom="basicFrom" :range="range"></BasicDrawer>
  44. </view>
  45. </view>
  46. </PublicDrawer>
  47. </scroll-view>
  48. </uni-drawer>
  49. <!-- 右侧抽屉结束 -->
  50. </view>
  51. </template>
  52. <script>
  53. import baseDateTable from './baseData-table/baseDateTable'
  54. import BasicDrawer from './BasicDrawer'
  55. export default {
  56. name: 'BasicData',
  57. components: {
  58. baseDateTable,
  59. BasicDrawer
  60. },
  61. data() {
  62. return {
  63. popupMessage: '成功消息',
  64. popupType: 'success',
  65. formSelect: [{
  66. value: 0,
  67. text: "本地站控"
  68. },
  69. {
  70. value: 1,
  71. text: "云端"
  72. },
  73. ],
  74. basicFrom: {
  75. id: 0,
  76. CarDistance: null,
  77. CarPlate: undefined,
  78. CarVin: undefined,
  79. state: undefined,
  80. },
  81. range: [{
  82. value: 0,
  83. text: "停用"
  84. },
  85. {
  86. value: 1,
  87. text: "启用"
  88. },
  89. ],
  90. datalist: [],
  91. queryParams: {
  92. page: 1, //当前页
  93. pageSize: 10, //每页条数
  94. source: undefined, //来源
  95. vehiclePlate: undefined, //车牌号
  96. vehicleVin: undefined, //VIN码
  97. orderByField: 'id', //排序字段
  98. orderByWays: 'desc' //排序方式
  99. },
  100. total: 0, //总条数,
  101. loading: false,
  102. headers: [{
  103. label: '车牌号',
  104. key: 'vehiclePlate',
  105. widtd: 150
  106. }, {
  107. label: '车辆识别码(VIN码)',
  108. key: 'vehicleVin',
  109. widtd: 315
  110. }, {
  111. label: '前端电池距离(mm)',
  112. key: 'modelDistance',
  113. widtd: 210
  114. }, {
  115. label: '来源',
  116. key: 'source',
  117. widtd: 108,
  118. }, {
  119. label: '状态',
  120. key: 'state',
  121. widtd: 108,
  122. }, {
  123. label: '操作',
  124. key: 'id',
  125. widtd: 108,
  126. }],
  127. showLoadMore: false,
  128. loadMore: 'more',
  129. dialogType: 'new', // 按钮类型(new、edit)
  130. EditCarForm: {}, //编辑车辆表单数据接收
  131. synchronizationTime:'',//同步时间
  132. }
  133. },
  134. mounted() {
  135. this.vehicleList();
  136. this.getsynchronization()
  137. },
  138. methods: {
  139. //顶部公共消息提示
  140. ExchangeMessage(type, message) {
  141. this.popupType = type
  142. this.popupMessage = message ? message : '后端接口404错误!'
  143. this.$refs.Exchangepopup.open()
  144. },
  145. //获取最近同步时间
  146. getsynchronization(){
  147. this.$http.getSyncTime().then(res=>{
  148. if(res.code == 0){
  149. this.synchronizationTime = res.data
  150. }
  151. })
  152. },
  153. //删除车辆
  154. DelCarData(id) {
  155. let that = this
  156. uni.showModal({
  157. title: `确认删除车辆信息吗?`,
  158. content: '',
  159. success: function(res) {
  160. if (res.confirm) {
  161. that.$http.delvehicle(id + '')
  162. .then(res => {
  163. if (res.code === 0) {
  164. that.vehicleList()
  165. }
  166. that.ExchangeMessage(res.code === 0 ? 'success' : 'error', res.msg)
  167. }).catch(err => {
  168. console.error(err)
  169. })
  170. } else if (res.cancel) {
  171. return false
  172. //用户点击取消按钮触发
  173. }
  174. }
  175. })
  176. },
  177. // 打开添加车辆抽屉
  178. OpenAddDrawer() {
  179. this.dialogType = 'new'
  180. this.basicFrom = {
  181. id: 0,
  182. CarDistance: null,
  183. CarPlate: undefined,
  184. CarVin: undefined,
  185. state: undefined,
  186. }
  187. this.$refs.BasicDrawer.open();
  188. },
  189. //打开编辑车辆抽屉
  190. EditCarData(row) {
  191. console.log(row)
  192. this.dialogType = 'edit'
  193. this.$refs.BasicDrawer.open();
  194. this.basicFrom.CarDistance = row.modelDistance
  195. this.basicFrom.CarPlate = row.vehiclePlate
  196. this.basicFrom.CarVin = row.vehicleVin
  197. this.basicFrom.state = row.state
  198. this.basicFrom.id = row.id
  199. },
  200. //编辑车辆请求接口
  201. EditCarInfo() {
  202. if (!this.basicFrom.CarDistance || !this.basicFrom.CarPlate || !this.basicFrom.CarVin) {
  203. this.ExchangeMessage('warn', '请填写完整!')
  204. } else {
  205. const params = {
  206. modelDistance: this.basicFrom.CarDistance,
  207. vehiclePlate: this.basicFrom.CarPlate,
  208. vehicleVin: this.basicFrom.CarVin,
  209. state: this.basicFrom.state * 1,
  210. id: this.basicFrom.id
  211. }
  212. this.$http.Editvehicle(params)
  213. .then(res => {
  214. this.closeDrawer()
  215. this.ExchangeMessage(res.code === 0 ? 'success' : 'error', res.msg)
  216. if (res.code === 0) {
  217. this.vehicleList()
  218. }
  219. }).catch(err => {
  220. console.error(err)
  221. })
  222. }
  223. },
  224. // 添加车辆请求接口
  225. AddCarinfo() {
  226. if (!this.basicFrom.CarDistance || !this.basicFrom.CarPlate || !this.basicFrom.CarVin) {
  227. this.ExchangeMessage('warn', '请填写完整!')
  228. } else {
  229. const params = {
  230. modelDistance: this.basicFrom.CarDistance,
  231. vehiclePlate: this.basicFrom.CarPlate,
  232. vehicleVin: this.basicFrom.CarVin,
  233. state: this.basicFrom.state * 1
  234. }
  235. this.$http.addvehicle(params)
  236. .then(res => {
  237. this.closeDrawer()
  238. this.ExchangeMessage(res.code === 0 ? 'success' : 'error', res.msg)
  239. if (res.code === 0) {
  240. this.vehicleList()
  241. }
  242. }).catch(err => {
  243. console.error(err)
  244. })
  245. }
  246. },
  247. //查询
  248. handleQuery() {
  249. this.queryParams.page = 1
  250. this.datalist = []
  251. this.showLoadMore = false
  252. this.vehicleList()
  253. },
  254. //重置
  255. resetForm() {
  256. this.queryParams = {
  257. page: 1,
  258. pageSize: 10,
  259. source: undefined, //来源
  260. vehiclePlate: undefined, //车牌号
  261. vehicleVin: undefined, //VIN码
  262. }
  263. this.vehicleList()
  264. },
  265. //车辆列表,
  266. vehicleList() {
  267. console.log(this.queryParams)
  268. this.$http.vehicleList(this.queryParams).then((res) => {
  269. this.datalist = res.data.records;
  270. this.total = res.data.total;
  271. });
  272. },
  273. //关闭抽屉
  274. closeDrawer() {
  275. this.$refs.BasicDrawer.close();
  276. },
  277. //触底加载数据
  278. pullup() {
  279. this.showLoadMore = true
  280. if (this.total == this.datalist.length) {
  281. this.loadMore = 'no-more'
  282. return
  283. } else {
  284. this.queryParams.page++
  285. this.vehicleList()
  286. this.loadMore = 'loading'
  287. }
  288. },
  289. //同步云端
  290. syncCloud() {
  291. let that = this
  292. uni.showModal({
  293. title: "是否同步云端",
  294. content: "",
  295. success: function(res) {
  296. if (res.confirm) {
  297. that.$http.getSync().then(res=>{
  298. that.ExchangeMessage(res.code === 0 ? 'success' : 'error', res.msg)
  299. })
  300. //用户点击确认按钮触发
  301. } else if (res.cancel) {
  302. return
  303. //用户点击取消按钮触发
  304. }
  305. }
  306. })
  307. },
  308. change(e) {
  309. },
  310. }
  311. }
  312. </script>
  313. <style lang="scss" scoped>
  314. ::v-deep .uni-forms-item__content {
  315. background: rgba(255, 255, 255, 0);
  316. border-radius: 2px;
  317. border: 1px solid #263042;
  318. .uni-select {
  319. border: none;
  320. }
  321. .uni-select__selector {
  322. background: none;
  323. border: 1px solid #263042;
  324. }
  325. .uni-select__selector-item {
  326. font-size: 14px;
  327. font-weight: 400;
  328. color: #A8ADC8;
  329. }
  330. .uni-popper__arrow {
  331. display: none;
  332. }
  333. .uni-select__input-text {
  334. color: white;
  335. }
  336. .uni-easyinput__content {
  337. background: none !important;
  338. border: none !important;
  339. color: #fff;
  340. width: 188px;
  341. }
  342. }
  343. ::v-deep .uni-forms-item__label {
  344. font-size: 14px;
  345. font-weight: 400;
  346. color: #FFFFFF;
  347. }
  348. ::v-deep .uni-select__selector {
  349. background: #111827 !important;
  350. border: 1px solid #263042;
  351. color: #606266;
  352. z-index: 9999999;
  353. }
  354. .basic-data {
  355. width: 100%;
  356. height: 100%;
  357. color: white;
  358. font-size: 24px;
  359. overflow: hidden;
  360. .basic-top {
  361. display: flex;
  362. .times {
  363. font-size: 14px;
  364. font-weight: 400;
  365. color: #A8ADC8;
  366. line-height: 32px;
  367. }
  368. .sync-btn {
  369. width: 88px;
  370. height: 32px;
  371. border-radius: 2px;
  372. line-height: 32px;
  373. text-align: center;
  374. border: 1px solid #91FDB9;
  375. font-size: 14px;
  376. font-weight: 400;
  377. color: #91FDB9;
  378. margin-left: 20px;
  379. }
  380. .title {
  381. margin-left: auto;
  382. line-height: 32px;
  383. font-size: 16px;
  384. font-weight: 600;
  385. color: rgba(255, 255, 255, 0.85);
  386. line-height: 19px;
  387. text-shadow: 0px 0px 4px #0027D8
  388. }
  389. }
  390. .basic-search {
  391. display: flex;
  392. padding: 16px 20px;
  393. width: 100%;
  394. height: 66px;
  395. box-sizing: border-box;
  396. background: #111827;
  397. box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
  398. border-radius: 2px;
  399. border: 1px solid #192337;
  400. margin-top: 20px;
  401. ::v-deep .searchForm {
  402. span {
  403. display: flex;
  404. }
  405. }
  406. }
  407. .search-btn {
  408. width: 60px;
  409. height: 34px;
  410. background: #91FDB9;
  411. border-radius: 2px;
  412. font-size: 14px;
  413. font-weight: 400;
  414. color: #000000;
  415. text-align: center;
  416. line-height: 34px;
  417. margin-left: 20px;
  418. margin-top: 1px;
  419. }
  420. .reset-btn {
  421. width: 60px;
  422. height: 32px;
  423. border-radius: 2px;
  424. font-size: 14px;
  425. font-weight: 400;
  426. color: #FFFFFF;
  427. text-align: center;
  428. line-height: 32px;
  429. margin-left: 20px;
  430. margin-top: 1px;
  431. border: 1px solid #263042;
  432. }
  433. .basic-table {
  434. width: 100%;
  435. height: 576px;
  436. background: #111827;
  437. box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
  438. border-radius: 2px;
  439. border: 1px solid #192337;
  440. margin-top: 16px;
  441. box-sizing: border-box;
  442. padding: 16px 20px;
  443. display: flex;
  444. flex-direction: column;
  445. .marginZero {
  446. margin-left: 0px;
  447. margin-bottom: 15px;
  448. }
  449. }
  450. }
  451. </style>