index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  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: 210
  106. }, {
  107. label: '车辆识别码(VIN码)',
  108. key: 'vehicleVin',
  109. widtd: 315
  110. }, {
  111. label: '前端电池距离(mm)',
  112. key: 'modelDistance',
  113. widtd: 200
  114. }, {
  115. label: '来源',
  116. key: 'source',
  117. widtd: 100,
  118. },
  119. // {
  120. // label: '状态',
  121. // key: 'state',
  122. // widtd: 108,
  123. // },
  124. {
  125. label: '操作',
  126. key: 'id',
  127. widtd: 108,
  128. },
  129. ],
  130. showLoadMore: false,
  131. loadMore: 'more',
  132. dialogType: 'new', // 按钮类型(new、edit)
  133. EditCarForm: {}, //编辑车辆表单数据接收
  134. synchronizationTime:'',//同步时间
  135. }
  136. },
  137. mounted() {
  138. this.vehicleList();
  139. this.getsynchronization()
  140. },
  141. methods: {
  142. //顶部公共消息提示
  143. ExchangeMessage(type, message) {
  144. this.popupType = type
  145. this.popupMessage = message ? message : '后端接口404错误!'
  146. this.$refs.Exchangepopup.open()
  147. },
  148. //获取最近同步时间
  149. getsynchronization(){
  150. this.$http.getSyncTime().then(res=>{
  151. if(res.code == 0){
  152. this.synchronizationTime = res.data
  153. }
  154. })
  155. },
  156. //删除车辆
  157. DelCarData(id) {
  158. let that = this
  159. uni.showModal({
  160. title: `确认删除车辆信息吗?`,
  161. content: '',
  162. success: function(res) {
  163. if (res.confirm) {
  164. that.$http.delvehicle(id + '')
  165. .then(res => {
  166. if (res.code === 0) {
  167. that.vehicleList()
  168. }
  169. that.ExchangeMessage(res.code === 0 ? 'success' : 'error', res.code === 0 ? '删除车辆成功' : '删除车辆失败')
  170. }).catch(err => {
  171. console.error(err)
  172. })
  173. } else if (res.cancel) {
  174. return false
  175. //用户点击取消按钮触发
  176. }
  177. }
  178. })
  179. },
  180. // 打开添加车辆抽屉
  181. OpenAddDrawer() {
  182. this.dialogType = 'new'
  183. this.basicFrom = {
  184. id: 0,
  185. CarDistance: null,
  186. CarPlate: undefined,
  187. CarVin: undefined,
  188. state: undefined,
  189. }
  190. this.$refs.BasicDrawer.open();
  191. },
  192. //打开编辑车辆抽屉
  193. EditCarData(row) {
  194. console.log(row)
  195. this.dialogType = 'edit'
  196. this.$refs.BasicDrawer.open();
  197. this.basicFrom.CarDistance = row.modelDistance
  198. this.basicFrom.CarPlate = row.vehiclePlate
  199. this.basicFrom.CarVin = row.vehicleVin
  200. this.basicFrom.state = row.state
  201. this.basicFrom.id = row.id
  202. },
  203. //编辑车辆请求接口
  204. EditCarInfo() {
  205. if (!this.basicFrom.CarDistance || !this.basicFrom.CarPlate || !this.basicFrom.CarVin) {
  206. this.ExchangeMessage('warn', '请填写完整!')
  207. } else {
  208. const params = {
  209. modelDistance: this.basicFrom.CarDistance,
  210. vehiclePlate: this.basicFrom.CarPlate,
  211. vehicleVin: this.basicFrom.CarVin,
  212. state: this.basicFrom.state * 1,
  213. id: this.basicFrom.id
  214. }
  215. this.$http.Editvehicle(params)
  216. .then(res => {
  217. this.closeDrawer()
  218. this.ExchangeMessage(res.code === 0 ? 'success' : 'error', res.msg)
  219. if (res.code === 0) {
  220. this.vehicleList()
  221. }
  222. }).catch(err => {
  223. console.error(err)
  224. })
  225. }
  226. },
  227. // 添加车辆请求接口
  228. AddCarinfo() {
  229. if (!this.basicFrom.CarDistance || !this.basicFrom.CarPlate || !this.basicFrom.CarVin) {
  230. this.ExchangeMessage('warn', '请填写完整!')
  231. } else {
  232. const params = {
  233. modelDistance: this.basicFrom.CarDistance,
  234. vehiclePlate: this.basicFrom.CarPlate,
  235. vehicleVin: this.basicFrom.CarVin,
  236. source: 0,
  237. }
  238. this.$http.addvehicle(params)
  239. .then(res => {
  240. this.closeDrawer()
  241. this.ExchangeMessage(res.code === 0 ? 'success' : 'error', res.code === 0 ? '新增车辆成功' : '新增车辆失败')
  242. if (res.code === 0) {
  243. this.vehicleList()
  244. }
  245. }).catch(err => {
  246. console.error(err)
  247. })
  248. }
  249. },
  250. //查询
  251. handleQuery() {
  252. this.queryParams.page = 1
  253. this.datalist = []
  254. this.showLoadMore = false
  255. this.vehicleList()
  256. },
  257. //重置
  258. resetForm() {
  259. this.queryParams = {
  260. page: 1,
  261. pageSize: 10,
  262. source: undefined, //来源
  263. vehiclePlate: undefined, //车牌号
  264. vehicleVin: undefined, //VIN码
  265. }
  266. this.vehicleList()
  267. },
  268. //车辆列表,
  269. vehicleList() {
  270. console.log(this.queryParams)
  271. this.$http.vehicleList(this.queryParams).then((res) => {
  272. this.datalist = res.data.records;
  273. this.total = res.data.total;
  274. });
  275. },
  276. //关闭抽屉
  277. closeDrawer() {
  278. this.$refs.BasicDrawer.close();
  279. },
  280. //触底加载数据
  281. pullup() {
  282. this.showLoadMore = true
  283. if (this.total == this.datalist.length) {
  284. this.loadMore = 'no-more'
  285. return
  286. } else {
  287. this.queryParams.page++
  288. this.vehicleList()
  289. this.loadMore = 'loading'
  290. }
  291. },
  292. //同步云端
  293. syncCloud() {
  294. let that = this
  295. uni.showModal({
  296. title: "是否同步云端",
  297. content: "",
  298. success: function(res) {
  299. if (res.confirm) {
  300. that.$http.getSync().then(res=>{
  301. that.ExchangeMessage(res.code === 0 ? 'success' : 'error', res.msg)
  302. })
  303. //用户点击确认按钮触发
  304. } else if (res.cancel) {
  305. return
  306. //用户点击取消按钮触发
  307. }
  308. }
  309. })
  310. },
  311. change(e) {
  312. },
  313. }
  314. }
  315. </script>
  316. <style lang="scss" scoped>
  317. ::v-deep .uni-forms-item__content {
  318. background: rgba(255, 255, 255, 0);
  319. border-radius: 2px;
  320. border: 1px solid #263042;
  321. .uni-select {
  322. border: none;
  323. }
  324. .uni-select__selector {
  325. background: none;
  326. border: 1px solid #263042;
  327. }
  328. .uni-select__selector-item {
  329. font-size: 14px;
  330. font-weight: 400;
  331. color: #A8ADC8;
  332. }
  333. .uni-popper__arrow {
  334. display: none;
  335. }
  336. .uni-select__input-text {
  337. color: white;
  338. }
  339. .uni-easyinput__content {
  340. background: none !important;
  341. border: none !important;
  342. color: #fff;
  343. width: 188px;
  344. }
  345. }
  346. ::v-deep .uni-forms-item__label {
  347. font-size: 14px;
  348. font-weight: 400;
  349. color: #FFFFFF;
  350. }
  351. ::v-deep .uni-select__selector {
  352. background: #111827 !important;
  353. border: 1px solid #263042;
  354. color: #606266;
  355. z-index: 9999999;
  356. }
  357. .basic-data {
  358. width: 100%;
  359. height: 100%;
  360. color: white;
  361. font-size: 24px;
  362. overflow: hidden;
  363. .basic-top {
  364. display: flex;
  365. .times {
  366. font-size: 14px;
  367. font-weight: 400;
  368. color: #A8ADC8;
  369. line-height: 32px;
  370. }
  371. .sync-btn {
  372. width: 88px;
  373. height: 32px;
  374. border-radius: 2px;
  375. line-height: 32px;
  376. text-align: center;
  377. border: 1px solid #91FDB9;
  378. font-size: 14px;
  379. font-weight: 400;
  380. color: #91FDB9;
  381. margin-left: 20px;
  382. }
  383. .title {
  384. margin-left: auto;
  385. line-height: 32px;
  386. font-size: 16px;
  387. font-weight: 600;
  388. color: rgba(255, 255, 255, 0.85);
  389. line-height: 19px;
  390. text-shadow: 0px 0px 4px #0027D8
  391. }
  392. }
  393. .basic-search {
  394. display: flex;
  395. padding: 16px 20px;
  396. width: 100%;
  397. height: 66px;
  398. box-sizing: border-box;
  399. background: #111827;
  400. box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
  401. border-radius: 2px;
  402. border: 1px solid #192337;
  403. margin-top: 20px;
  404. ::v-deep .searchForm {
  405. span {
  406. display: flex;
  407. }
  408. }
  409. }
  410. .search-btn {
  411. width: 60px;
  412. height: 34px;
  413. background: #91FDB9;
  414. border-radius: 2px;
  415. font-size: 14px;
  416. font-weight: 400;
  417. color: #000000;
  418. text-align: center;
  419. line-height: 34px;
  420. margin-left: 20px;
  421. margin-top: 1px;
  422. }
  423. .reset-btn {
  424. width: 60px;
  425. height: 32px;
  426. border-radius: 2px;
  427. font-size: 14px;
  428. font-weight: 400;
  429. color: #FFFFFF;
  430. text-align: center;
  431. line-height: 32px;
  432. margin-left: 20px;
  433. margin-top: 1px;
  434. border: 1px solid #263042;
  435. }
  436. .basic-table {
  437. width: 100%;
  438. height: 576px;
  439. background: #111827;
  440. box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
  441. border-radius: 2px;
  442. border: 1px solid #192337;
  443. margin-top: 16px;
  444. box-sizing: border-box;
  445. padding: 16px 20px;
  446. display: flex;
  447. flex-direction: column;
  448. .marginZero {
  449. margin-left: 0px;
  450. margin-bottom: 15px;
  451. }
  452. }
  453. }
  454. </style>