jiangping
2024-11-12 95ddc157639fc6e9102d2e1fa8ca164af66685d6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
<template>
  <TableLayout :permissions="['business:empower:query']">
    <!-- 搜索表单 -->
    <el-form
      ref="searchForm"
      slot="search-form"
      :model="searchForm"
      label-width="100px"
      inline
    >
      <el-form-item label="申请人" prop="memberName">
        <el-input
          v-model="searchForm.memberName"
          placeholder="请输入姓名/手机号"
          @keypress.enter.native="search"
        ></el-input>
      </el-form-item>
      <el-form-item label="申请人组织" prop="companyName">
        <el-input
          v-model="searchForm.companyName"
          placeholder="请输入申请人组织"
          clearable
          @keypress.enter.native="search"
        ></el-input>
      </el-form-item>
      <el-form-item label="车牌号" prop="carCode">
        <el-input
          v-model="searchForm.carCode"
          placeholder="请输入车牌号"
          clearable
          @keypress.enter.native="search"
        ></el-input>
      </el-form-item>
      <el-form-item label="状态" prop="status">
        <el-select
          v-model="searchForm.status"
          @change="search"
          clearable
          placeholder="状态"
        >
          <el-option label="申请中" value="0"></el-option>
          <el-option label="审核中" value="1"></el-option>
          <el-option label="审批通过" value="2"></el-option>
          <el-option label="审批不通过" value="3"></el-option>
          <el-option label="已撤销" value="4"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="目的地类型" prop="type">
        <el-select
          v-model="searchForm.type"
          @change="search"
          clearable
          placeholder="目的地类型"
        >
          <el-option label="市内用车" value="0"></el-option>
          <el-option label="市外用车" value="1"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="出发时间" prop="startTime">
        <el-date-picker
          @change="seleTime"
          v-model="time"
          @keypress.enter.native="search"
          type="datetimerange"
          format="yyyy-MM-dd HH:mm:ss"
          value-format="yyyy-MM-dd HH:mm:ss"
          :default-time="['00:00:00', '23:59:59']"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        >
        </el-date-picker>
      </el-form-item>
      <el-radio-group
        v-model="searchForm.radio"
        size="small"
        @input="changeRadio"
      >
        <el-radio-button label="0">当天</el-radio-button>
        <el-radio-button label="1">近7天</el-radio-button>
        <el-radio-button label="2">近30天</el-radio-button>
      </el-radio-group>
      <section>
        <el-button type="primary" @click="search">搜索</el-button>
        <el-button @click="reset">重置</el-button>
      </section>
    </el-form>
    <!-- 表格和分页 -->
    <template v-slot:table-wrap>
      <ul
        class="toolbar"
        v-permissions="[
          'business:carusebook:create',
          'business:carusebook:exportExcel',
        ]"
      >
        <li>
          <el-button
            type="primary"
            @click="handleEdit"
            icon="el-icon-plus"
            v-permissions="['business:carusebook:create']"
            >新建</el-button
          >
        </li>
        <li>
          <el-button
            type="primary"
            @click="handleEx"
            v-permissions="['business:carusebook:exportExcel']"
            >导出</el-button
          >
        </li>
      </ul>
      <el-table
        v-loading="isWorking.search"
        :data="tableData.list"
        stripe
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" width="55"></el-table-column>
        <el-table-column
            prop="carCode"
            label="车牌号"
            min-width="100px"
        ></el-table-column>
        <el-table-column
          prop="memberName"
          label="提报人"
          min-width="80px"
        ></el-table-column>
        <el-table-column
          prop="companyName"
          label="所属组织"
          min-width="150px"
        ></el-table-column>
        <el-table-column label="用车时间" min-width="170px">
          <template slot-scope="{ row }">
            <span v-if="row.startTime">起:{{ row.startTime.slice(0,16) }}</span
            ><br />
            <span v-if="row.endTime">止:{{ row.endTime.slice(0,16) }}</span>
          </template>
        </el-table-column>
        <el-table-column
            prop="memberNames"
            label="乘车人"
            min-width="180px"
        ></el-table-column>
        <el-table-column
          prop="planUseDate"
          label="出发时间"
          min-width="150px"
        >
        <template slot-scope="{ row }">
          <span v-if="row.planUseDate">{{ row.planUseDate.slice(0,16) }}</span>
        </template>
      </el-table-column>
        <el-table-column label="目的地" min-width="200px">
          <template slot-scope="{ row }">
            <span class="status-green" v-if="row.type === 0">【市内】</span>
            <span class="status-red" v-if="row.type === 1">【市外】</span>
            <span>{{ row.addr }}</span>
          </template>
        </el-table-column>
        <el-table-column label="状态" min-width="100px">
          <template slot-scope="{ row }">
            <span class="status-blue" v-if="row.status === 0">申请中</span>
            <span class="status-blue" v-if="row.status === 1">审核中</span>
            <span class="status-green" v-if="row.status === 2">审批通过</span>
            <span class="status-red" v-if="row.status === 3">审批不通过</span>
            <span class="status-red" v-if="row.status === 4">已撤销</span>
          </template>
        </el-table-column>
 
        <el-table-column
          prop="createDate"
          label="申请时间"
          min-width="150px"
        ></el-table-column>
        <el-table-column
          prop="editDate"
          label="操作时间"
          min-width="150px"
        ></el-table-column>
        <el-table-column
          label="操作"
          min-width="160"
          align="center"
          fixed="right"
        >
          <template slot-scope="{ row }">
            <el-button
              type="text"
              icon="el-icon-edit"
              @click="$refs.OperaDetailsWindow.open('公务车申请详情', row)"
              >查看详情</el-button
            >
            <!-- <el-button v-if="(row.status === 1 || row.status === 2) && new Date().getTime() < new Date(row.startTime).getTime()" type="text" icon="el-icon-delete" @click="rowRevokeClick(row)" >撤销</el-button> -->
            <el-button
              v-if="
                (row.status === 0 || row.status === 1 || row.status === 2) &&
                new Date().getTime() < new Date(row.startTime).getTime()
              "
              type="text"
              icon="el-icon-delete"
              @click="rowRevokeClick(row)"
              >撤销</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <pagination
        @size-change="handleSizeChange"
        @current-change="handlePageChange"
        :pagination="tableData.pagination"
      >
      </pagination>
    </template>
    <!--  -->
    <el-dialog title="用车撤销" :visible.sync="isShowBack" width="520px">
      <el-form
        :model="backParam"
        :rules="rules"
        ref="backForm"
        label-width="100px"
        class="demo-ruleForm"
      >
        <el-form-item label="说明" prop="info">
          <el-input
            type="textarea"
            :rows="4"
            v-model="backParam.info"
            placeholder="请输入撤销说明"
          ></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="isShowBack = false">取消</el-button>
        <el-button type="primary" @click="backSubmit">确定</el-button>
      </span>
    </el-dialog>
    <OperaCarUseBookWindow
      ref="OperaDetailsWindow"
      @success="handlePageChange"
    />
    <OperaCarUseBookParamWindow ref="OperaParamWindow" @success="search" />
  </TableLayout>
</template>
 
<script>
import BaseTable from '@/components/base/BaseTable'
import TableLayout from '@/layouts/TableLayout'
import Pagination from '@/components/common/Pagination'
import OperaCarUseBookWindow from '@/components/business/OperaCarUseBookWindow'
import OperaCarUseBookParamWindow from '@/components/operation/OperCarUseBookParamWindow.vue'
import { timeForMat } from '@/utils/util'
import { allList } from '@/api/business/hiddenDangerParam'
import { carUseBookRecordEx, revokeById } from '@/api/business/carUseBook'
export default {
  name: 'Empower',
  extends: BaseTable,
  components: { TableLayout, Pagination, OperaCarUseBookWindow, OperaCarUseBookParamWindow },
  data () {
    return {
      // 搜索
      searchForm: {
        memberName: '',
        companyName: '',
        queryStartTime: '',
        queryEndTime: '',
        type: null,
        status: null,
        radio: 0
      },
      cateList: [],
      areaList: [],
      time: [],
 
      isShowBack: false,
      backParam: {},
      rules: {
        info: [{ required: true, message: '请输入', trigger: 'blur' }]
      }
    }
  },
  created () {
    this.config({
      module: '用车申请管理',
      api: '/business/carUseBook',
      'field.id': 'id',
      'field.main': 'id'
    })
    // this.search()
    this.changeRadio('0')
    this.loadParams()
  },
  methods: {
    rowRevokeClick (row) {
      this.isShowBack = true
      this.backParam = {}
      this.$set(this.backParam, 'id', row.id)
      this.$nextTick(() => {
        this.$refs.backForm.clearValidate()
      })
    },
    backSubmit () {
      revokeById({ ...this.backParam }).then(res => {
        this.$tip.success('撤销成功')
        this.isShowBack = false
        this.search()
      })
    },
    handleEx () {
      this.$dialog.exportConfirm('确认导出吗?')
        .then(() => {
          this.exLoading = true
          carUseBookRecordEx({
            model: this.searchForm
          })
            .then(response => {
              this.download(response)
            })
            .catch(e => {
            })
            .finally(() => {
              this.exLoading = false
            })
        })
    },
    changeRadio (e) {
      this.searchForm.radio = e
      if (e === '0') {
        this.searchForm.queryStartTime = timeForMat(0)[0]
        this.searchForm.queryEndTime = timeForMat(0)[1]
        this.time = timeForMat(0)
      } else if (e === '1') {
        this.searchForm.queryStartTime = timeForMat(6)[0]
        this.searchForm.queryEndTime = timeForMat(6)[1]
        this.time = timeForMat(6)
      } else if (e === '2') {
        this.searchForm.queryStartTime = timeForMat(29)[0]
        this.searchForm.queryEndTime = timeForMat(29)[1]
        this.time = timeForMat(29)
      }
      this.search()
    },
    handleEdit () {
      this.$refs.OperaParamWindow.open()
    },
    loadParams () {
      allList({
      })
        .then(res => {
          if (res != null && res.length) {
            res.forEach(item => {
              if (item && item.type != null && item.type === 0) {
                this.areaList.push(item)
              }
              if (item && item.type != null && item.type === 1) {
                this.cateList.push(item)
              }
            })
          }
        })
        .catch(e => {
          // this.$tip.apiFailed(e)
        })
        .finally(() => {
        })
    },
    seleTime (e) {
      this.searchForm.queryStartTime = e[0]
      this.searchForm.queryEndTime = e[1]
      this.searchForm.radio = null
      this.search()
    },
    reset () {
      this.$refs.searchForm.resetFields()
      this.searchForm.radio = '0'
      this.changeRadio('0')
      // this.search()
    }
  }
}
</script>