123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479 |
- <template>
- <view class="basic-data">
- <view class="basic-top">
- <view class="times">最近同步时间:{{synchronizationTime || '-'}}</view>
- <view class="sync-btn" @click="syncCloud">云端同步</view>
- <view class="title">车辆管理</view>
- </view>
- <view class="basic-search">
- <uni-forms ref="form" :modelValue="queryParams" class="searchForm">
- <uni-forms-item label="车牌号码:" label-width="72px" label-align="right" name="vehiclePlate">
- <uni-easyinput type="text" v-model="queryParams.vehiclePlate" placeholder="请输入车牌号码" />
- </uni-forms-item>
- <uni-forms-item label="车辆识别码:" label-width="128px" label-align="right" name="vehicleVin">
- <uni-easyinput type="text" v-model="queryParams.vehicleVin" placeholder="请输入车辆识别码" />
- </uni-forms-item>
- <uni-forms-item label="来源:" label-width="80px" label-align="right">
- <uni-data-select v-model="queryParams.source" :localdata="formSelect" style="width: 100px;"
- @change="change"></uni-data-select>
- </uni-forms-item>
- </uni-forms>
- <view class="search-btn" @click="handleQuery">查询</view>
- <view class="reset-btn" @click="resetForm">重置</view>
- </view>
- <view class="basic-table">
- <view class="search-btn marginZero" @click="OpenAddDrawer">新增</view>
- <baseDateTable @DelCarData="DelCarData" @EditCarData="EditCarData" :headerFixed="true"
- :showLoadMore="showLoadMore" :loadMore="loadMore" :columnFixed=1 :contents="datalist" :headers="headers"
- @onPullup="pullup">
- </baseDateTable>
- </view>
- <!-- 顶部公共提示信息 -->
- <uni-popup ref="Exchangepopup" type="message">
- <uni-popup-message :type="popupType" :message="popupMessage" :duration="2000"></uni-popup-message>
- </uni-popup>
- <!-- 顶部提示信息结束-->
- <!--右侧抽屉 -->
- <uni-drawer ref="BasicDrawer" mode="right" :width="400" :mask-click="true">
- <scroll-view style="height: 100%;" scroll-y="true">
- <PublicDrawer :flag="false" :title="dialogType=='new'?'新增车辆':'编辑车辆'" @closeDrawer="closeDrawer"
- @AddCarinfo="AddCarinfo" @EditCarInfo="EditCarInfo">
- <view class="drawer_main">
- <view>
- <BasicDrawer :basicFrom="basicFrom" :range="range"></BasicDrawer>
- </view>
- </view>
- </PublicDrawer>
- </scroll-view>
- </uni-drawer>
- <!-- 右侧抽屉结束 -->
- </view>
- </template>
- <script>
- import baseDateTable from './baseData-table/baseDateTable'
- import BasicDrawer from './BasicDrawer'
- export default {
- name: 'BasicData',
- components: {
- baseDateTable,
- BasicDrawer
- },
- data() {
- return {
- popupMessage: '成功消息',
- popupType: 'success',
- formSelect: [{
- value: 0,
- text: "站控"
- },
- {
- value: 1,
- text: "云端"
- },
- ],
- basicFrom: {
- id: 0,
- CarDistance: null,
- CarPlate: undefined,
- CarVin: undefined,
- state: undefined,
- },
- range: [{
- value: 0,
- text: "停用"
- },
- {
- value: 1,
- text: "启用"
- },
- ],
- datalist: [],
- queryParams: {
- page: 1, //当前页
- pageSize: 10, //每页条数
- source: undefined, //来源
- vehiclePlate: undefined, //车牌号
- vehicleVin: undefined, //VIN码
- orderByField: 'id', //排序字段
- orderByWays: 'desc' //排序方式
- },
- total: 0, //总条数,
- loading: false,
- headers: [{
- label: '车牌号',
- key: 'vehiclePlate',
- widtd: 210
- }, {
- label: '车辆识别码(VIN码)',
- key: 'vehicleVin',
- widtd: 315
- }, {
- label: '前端电池距离(mm)',
- key: 'modelDistance',
- widtd: 200
- }, {
- label: '来源',
- key: 'source',
- widtd: 100,
- },
- // {
- // label: '状态',
- // key: 'state',
- // widtd: 108,
- // },
- {
- label: '操作',
- key: 'id',
- widtd: 108,
- },
- ],
- showLoadMore: false,
- loadMore: 'more',
- dialogType: 'new', // 按钮类型(new、edit)
- EditCarForm: {}, //编辑车辆表单数据接收
- synchronizationTime:'',//同步时间
- }
- },
- mounted() {
- this.vehicleList();
- this.getsynchronization()
- },
- methods: {
- //顶部公共消息提示
- ExchangeMessage(type, message) {
- this.popupType = type
- this.popupMessage = message ? message : '后端接口404错误!'
- this.$refs.Exchangepopup.open()
- },
- //获取最近同步时间
- getsynchronization(){
- this.$http.getSyncTime().then(res=>{
- if(res.code == 0){
- this.synchronizationTime = res.data
- }
- })
- },
- //删除车辆
- DelCarData(id) {
- let that = this
- uni.showModal({
- title: `确认删除车辆信息吗?`,
- content: '',
- success: function(res) {
- if (res.confirm) {
- that.$http.delvehicle(id + '')
- .then(res => {
- if (res.code === 0) {
- that.vehicleList()
- }
- that.ExchangeMessage(res.code === 0 ? 'success' : 'error', res.code === 0 ? '删除车辆成功' : '删除车辆失败')
- }).catch(err => {
- console.error(err)
- })
- } else if (res.cancel) {
- return false
- //用户点击取消按钮触发
- }
- }
- })
- },
- // 打开添加车辆抽屉
- OpenAddDrawer() {
- this.dialogType = 'new'
- this.basicFrom = {
- id: 0,
- CarDistance: null,
- CarPlate: undefined,
- CarVin: undefined,
- state: undefined,
- }
- this.$refs.BasicDrawer.open();
- },
- //打开编辑车辆抽屉
- EditCarData(row) {
- console.log(row)
- this.dialogType = 'edit'
- this.$refs.BasicDrawer.open();
- this.basicFrom.CarDistance = row.modelDistance
- this.basicFrom.CarPlate = row.vehiclePlate
- this.basicFrom.CarVin = row.vehicleVin
- this.basicFrom.state = row.state
- this.basicFrom.id = row.id
- },
- //编辑车辆请求接口
- EditCarInfo() {
- if (!this.basicFrom.CarDistance || !this.basicFrom.CarPlate || !this.basicFrom.CarVin) {
- this.ExchangeMessage('warn', '请填写完整!')
- } else {
- const params = {
- modelDistance: this.basicFrom.CarDistance,
- vehiclePlate: this.basicFrom.CarPlate,
- vehicleVin: this.basicFrom.CarVin,
- state: this.basicFrom.state * 1,
- id: this.basicFrom.id
- }
- this.$http.Editvehicle(params)
- .then(res => {
- this.closeDrawer()
- this.ExchangeMessage(res.code === 0 ? 'success' : 'error', res.msg)
- if (res.code === 0) {
- this.vehicleList()
- }
- }).catch(err => {
- console.error(err)
- })
- }
- },
- // 添加车辆请求接口
- AddCarinfo() {
- if (!this.basicFrom.CarDistance || !this.basicFrom.CarPlate || !this.basicFrom.CarVin) {
- this.ExchangeMessage('warn', '请填写完整!')
- } else {
- const params = {
- modelDistance: this.basicFrom.CarDistance,
- vehiclePlate: this.basicFrom.CarPlate,
- vehicleVin: this.basicFrom.CarVin,
- source: 0,
- }
- this.$http.addvehicle(params)
- .then(res => {
- this.closeDrawer()
- this.ExchangeMessage(res.code === 0 ? 'success' : 'error', res.code === 0 ? '新增车辆成功' : '新增车辆失败')
- if (res.code === 0) {
- this.vehicleList()
- }
- }).catch(err => {
- console.error(err)
- })
- }
- },
- //查询
- handleQuery() {
- this.queryParams.page = 1
- this.datalist = []
- this.showLoadMore = false
- this.vehicleList()
- },
- //重置
- resetForm() {
- this.queryParams = {
- page: 1,
- pageSize: 10,
- source: undefined, //来源
- vehiclePlate: undefined, //车牌号
- vehicleVin: undefined, //VIN码
- }
- this.vehicleList()
- },
- //车辆列表,
- vehicleList() {
- console.log(this.queryParams)
- this.$http.vehicleList(this.queryParams).then((res) => {
- this.datalist = res.data.records;
- this.total = res.data.total;
- });
- },
- //关闭抽屉
- closeDrawer() {
- this.$refs.BasicDrawer.close();
- },
- //触底加载数据
- pullup() {
- this.showLoadMore = true
- if (this.total == this.datalist.length) {
- this.loadMore = 'no-more'
- return
- } else {
- this.queryParams.page++
- this.vehicleList()
- this.loadMore = 'loading'
- }
- },
- //同步云端
- syncCloud() {
- let that = this
- uni.showModal({
- title: "是否同步云端",
- content: "",
- success: function(res) {
- if (res.confirm) {
- that.$http.getSync().then(res=>{
- that.ExchangeMessage(res.code === 0 ? 'success' : 'error', res.msg)
- })
- //用户点击确认按钮触发
- } else if (res.cancel) {
- return
- //用户点击取消按钮触发
- }
- }
- })
-
- },
- change(e) {
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- ::v-deep .uni-forms-item__content {
- background: rgba(255, 255, 255, 0);
- border-radius: 2px;
- border: 1px solid #263042;
- .uni-select {
- border: none;
- }
- .uni-select__selector {
- background: none;
- border: 1px solid #263042;
- }
- .uni-select__selector-item {
- font-size: 14px;
- font-weight: 400;
- color: #A8ADC8;
- }
- .uni-popper__arrow {
- display: none;
- }
- .uni-select__input-text {
- color: white;
- }
- .uni-easyinput__content {
- background: none !important;
- border: none !important;
- color: #fff;
- width: 188px;
- }
- }
- ::v-deep .uni-forms-item__label {
- font-size: 14px;
- font-weight: 400;
- color: #FFFFFF;
- }
- ::v-deep .uni-select__selector {
- background: #111827 !important;
- border: 1px solid #263042;
- color: #606266;
- z-index: 9999999;
- }
- .basic-data {
- width: 100%;
- height: 100%;
- color: white;
- font-size: 24px;
- overflow: hidden;
- .basic-top {
- display: flex;
- .times {
- font-size: 14px;
- font-weight: 400;
- color: #A8ADC8;
- line-height: 32px;
- }
- .sync-btn {
- width: 88px;
- height: 32px;
- border-radius: 2px;
- line-height: 32px;
- text-align: center;
- border: 1px solid #91FDB9;
- font-size: 14px;
- font-weight: 400;
- color: #91FDB9;
- margin-left: 20px;
- }
- .title {
- margin-left: auto;
- line-height: 32px;
- font-size: 16px;
- font-weight: 600;
- color: rgba(255, 255, 255, 0.85);
- line-height: 19px;
- text-shadow: 0px 0px 4px #0027D8
- }
- }
- .basic-search {
- display: flex;
- padding: 16px 20px;
- width: 100%;
- height: 66px;
- box-sizing: border-box;
- background: #111827;
- box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
- border-radius: 2px;
- border: 1px solid #192337;
- margin-top: 20px;
- ::v-deep .searchForm {
- span {
- display: flex;
- }
- }
- }
- .search-btn {
- width: 60px;
- height: 34px;
- background: #91FDB9;
- border-radius: 2px;
- font-size: 14px;
- font-weight: 400;
- color: #000000;
- text-align: center;
- line-height: 34px;
- margin-left: 20px;
- margin-top: 1px;
- }
- .reset-btn {
- width: 60px;
- height: 32px;
- border-radius: 2px;
- font-size: 14px;
- font-weight: 400;
- color: #FFFFFF;
- text-align: center;
- line-height: 32px;
- margin-left: 20px;
- margin-top: 1px;
- border: 1px solid #263042;
- }
- .basic-table {
- width: 100%;
- height: 576px;
- background: #111827;
- box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
- border-radius: 2px;
- border: 1px solid #192337;
- margin-top: 16px;
- box-sizing: border-box;
- padding: 16px 20px;
- display: flex;
- flex-direction: column;
- .marginZero {
- margin-left: 0px;
- margin-bottom: 15px;
- }
- }
- }
- </style>
|