MrShi
2025-03-31 991c2109853e08eef374512fffd111706fa5bf84
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
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
<template>
  <div class="main_app">
    <QueryForm v-model="filters" :query-form-config="queryFormConfig" @changeForm='changeForm' @handleQuery="getList(1)"
      @clear="clear">
      <template #fastdate>
        <el-radio-group v-model="filters.fastdate" size="small" @input="changeRadio">
          <el-radio-button label="0">当天</el-radio-button>
          <el-radio-button label="6">近7天</el-radio-button>
          <el-radio-button label="29">近30天</el-radio-button>
        </el-radio-group>
      </template>
    </QueryForm>
    <div class="pt16">
      <el-button type="primary" @click="handleEdit" icon="el-icon-plus"
        v-permissions="['business:platformbooks:create']">新建</el-button>
      <el-button type="primary" @click="complete(ids)">完成作业</el-button>
      <el-button :loading="exLoading" @click="handleEx"
        v-permissions="['business:platformbooks:exportExcel']">导出</el-button>
    </div>
    <el-table :height="tableHeightNew" v-loading="loading" :data="list" @selection-change="handleSelectionChange" stripe>
      <el-table-column type="selection" width="55"></el-table-column>
      <el-table-column prop="contractNum" label="合同/单据编号" min-width="100" show-overflow-tooltip />
      <el-table-column prop="inReason" label="入园原因" min-width="100" show-overflow-tooltip />
      <el-table-column prop="totalNum" label="总作业量(万支)" min-width="100" show-overflow-tooltip />
      <el-table-column prop="carCodeFront" label="车牌前照号" min-width="100" show-overflow-tooltip />
      <el-table-column prop="carCodeBack" label="车牌后照号" min-width="100" show-overflow-tooltip />
      <el-table-column prop="driverName" label="驾驶员" min-width="100" show-overflow-tooltip />
      <el-table-column prop="driverPhone" label="联系方式" min-width="100" show-overflow-tooltip />
      <el-table-column prop="inTypeTemp" label="作业类型" min-width="100" show-overflow-tooltip />
      <el-table-column label="作业状态" min-width="100" show-overflow-tooltip>
        <template v-slot="scope">
          <span v-if="[2,3,4].includes(scope.row.status)">{{ statusMap[scope.row.jobStatus] || '' }}</span>
          <span v-else>-</span>
        </template>
      </el-table-column>
      <el-table-column prop="arriveDate" label="预约到场时间" min-width="150" show-overflow-tooltip />
      <el-table-column label="审批结果" min-width="100" show-overflow-tooltip>
        <template v-slot="scope">
          <span v-if="scope.row.status == '0'">待审批</span>
          <span v-if="scope.row.status == '1'">审批中</span>
          <span v-if="scope.row.status == '2'">审批通过</span>
          <span v-if="scope.row.status == '3'">审批驳回</span>
          <span v-if="scope.row.status == '4'">已取消</span>
        </template>
      </el-table-column>
      <el-table-column prop="auditName" label="当前审批人" min-width="100" show-overflow-tooltip />
      <el-table-column prop="editDate" label="操作时间" min-width="150" show-overflow-tooltip />
      <el-table-column prop="name" label="操作" min-width="170" align="center" fixed="right" show-overflow-tooltip>
        <template v-slot="scope">
          <el-button type="text" v-permissions="['business:platformbooks:detail']"
            @click="handleDetail(scope.row)">预约详情</el-button>
          <el-button type="text" @click="complete([scope.row.jobId])" v-if="[0,1].includes(scope.row.jobStatus)">完成作业</el-button>
          <el-button type="text" class="red" v-permissions="['business:platformbooks:delete']"
            @click="handleDel(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination @size-change="handleSizeChange" @current-change="getList" :pagination="pagination" />
    <!--  -->
    <GlobalWindow :title="param.id ? '编辑物流车预约' : '新增物流车预约'" center :visible.sync="isShowEdit" width="600px"
      :confirm-working="subLoading" @confirm="onSubmit">
      <el-form :model="param" :rules="rules" ref="ruleForm" label-width="100px">
        <div class="param_title">运输信息</div>
        <el-form-item label="入园原因" prop="reasonId">
          <el-select v-model="param.reasonId" @change="checkSurplus" class="w300" placeholder="请选择">
            <el-option v-for="item in reasonList" :key="item.id" :label="item.reason" :value="item.id">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="合同/单据编号" prop="contractNum">
          <el-input v-model="param.contractNum" class="w300" placeholder="请输入合同/单据编号"></el-input>
        </el-form-item>
        <el-form-item label="到场时间" prop="arriveDate">
          <el-date-picker v-model="param.arriveDate" @change="checkSurplus" value-format="yyyy-MM-dd HH:mm:ss"
            type="datetime" class="w300" placeholder="请选择">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="作业类型" prop="inType">
          <div>
            <el-radio v-model="param.inType" :label="0">整件盘</el-radio>
            <el-radio v-model="param.inType" :label="1">件烟</el-radio>
          </div>
        </el-form-item>
        <el-form-item label="总运输量" prop="totalNum">
          <el-input @blur="checkSurplus" oninput="value=value.replace(/^(0+)|[^\d]+/g, '').slice(0, 10)"
            v-model="param.totalNum" placeholder="请输入" class="w300"></el-input>
          <span class="ml10">万支</span>
        </el-form-item>
        <el-form-item label="准运证/运单照片" prop="transportImg">
          <UploadAvatarImage :file="{ 'imgurlfull': param.transportImgFull, 'imgurl': param.transportImg }"
            :uploadData="{ folder: 'platform' }" @uploadSuccess="uploadSuccess" @uploadEnd="isUploading = false"
            @uploadBegin="isUploading = true" />
        </el-form-item>
        <div class="param_title">司机/车辆信息</div>
        <el-form-item label="司机姓名" prop="driverName">
          <el-input v-model="param.driverName" placeholder="请输入" class="w300"></el-input>
        </el-form-item>
        <el-form-item label="司机手机号" prop="driverPhone">
          <el-input oninput="value=value.replace(/^(0+)|[^\d]+/g, '').slice(0, 11)" v-model="param.driverPhone"
            placeholder="请输入" class="w300"></el-input>
        </el-form-item>
        <el-form-item label="车前牌照号" prop="carCodeFront">
          <el-input v-model="param.carCodeFront" placeholder="请输入" class="w300"></el-input>
        </el-form-item>
        <el-form-item label="车后牌照号" prop="carCodeBack">
          <el-input v-model="param.carCodeBack" placeholder="请输入" class="w300"></el-input>
        </el-form-item>
      </el-form>
    </GlobalWindow>
    <!--  -->
    <DriverDetail v-if="isShowDriver" @success="getList" @close="isShowDriver = false" ref="DriverDetailRef" />
  </div>
</template>
 
<script>
import Pagination from '@/components/common/Pagination'
import QueryForm from '@/components/common/QueryForm'
import { platformBooksPage, platformReasonList, platformBooksApply, platformBooksExport, dealJobFinish } from '@/api'
import { checkSurplusNum, deletebooksById } from '@/api/platform/platform'
import DriverDetail from '@/views/task/driverDetail'
import GlobalWindow from '@/components/common/GlobalWindow'
import UploadAvatarImage from '@/components/common/UploadAvatarImage'
import { Message } from 'element-ui'
import { statusMap } from '../config'
import dayjs from 'dayjs'
import BaseComputHeight from "@/components/base/BaseComputHeight"
export default {
  extends: BaseComputHeight,
  components: {
    Pagination,
    QueryForm,
    DriverDetail,
    GlobalWindow,
    UploadAvatarImage
  },
  data() {
    return {
      statusMap,
      isShowDriver: false,
      exLoading: false,
      loading: false,
      pagination: {
        pageSize: 10,
        page: 1,
        total: 0
      },
      filters: {
        arriveDateStart: '',
        arriveDateEnd: '',
        fastdate: 0
      },
      list: [],
 
      isShowEdit: false,
      subLoading: false,
      param: {
        inType: 0
      },
      reasonList: [],
      rules: {
        contractNum: [{ required: true, message: '请输入', trigger: 'blur' }],
        totalNum: [{ required: true, message: '请输入', trigger: 'blur' }],
        driverPhone: [{ required: true, message: '请输入', trigger: 'blur' }],
        carCodeFront: [{ required: true, message: '请输入', trigger: 'blur' }],
        carCodeBack: [{ required: true, message: '请输入', trigger: 'blur' }],
 
        transportImg: [{ required: true, message: '请上传', trigger: 'blur' }],
        reasonId: [{ required: true, message: '请选择', trigger: 'blur' }],
        arriveDate: [{ required: true, message: '请选择', trigger: 'blur' }],
        inType: [{ required: true, message: '请选择', trigger: 'blur' }],
        driverName: [{ required: true, message: '请选择', trigger: 'blur' }]
      },
      queryFormConfig: {
        formItems: [
          {
            filed: 'carCodeFront',
            type: 'input',
            label: '车牌号'
          },
          {
            filed: 'driverName',
            type: 'input',
            label: '驾驶员'
          },
          {
            filed: 'contractNum',
            type: 'input',
            label: '合同单号'
          },
          {
            filed: 'status',
            type: 'select',
            label: '审批结果',
            options: [
              { value: 0, label: '待审批' },
              { value: 1, label: '审批中' },
              { value: 2, label: '审批通过' },
              { value: 3, label: '审批驳回' },
              { value: 4, label: '已取消' }
            ]
          },
          {
            filed: 'reasonId',
            type: 'select',
            label: '入园原因',
            options: []
          },
          {
            filed1: 'arriveDateStart',
            filed2: 'arriveDateEnd',
            type: 'datetime',
            label: '操作时间'
          },
          {
            type: 'slot',
            filed: 'fastdate',
            label: ''
          }
        ],
        online: true
      },
      ids: []
    }
  },
  created() {
    this.changeRadio('0')
    this.getplatformReasons()
    // this.getList()
  },
  methods: {
    handleSelectionChange(ids) {
      this.ids = ids.map(item => item.jobId)
    },
    complete(ids) {
      var that = this;
      if (ids.length === 0) {
        return this.$message.warning('至少选择一项内容')
      }
      this.$confirm('是否确认完成作业?, 是否确认?', '提示', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        dealJobFinish(ids)
          .then(res => {
            that.getList()
          })
      }).catch(() => {
 
      });
    },
    checkSurplus() {
      const { arriveDate, reasonId, totalNum } = this.param
      if (!arriveDate || !reasonId || !totalNum) return
      checkSurplusNum({
        arriveDate,
        reasonId,
        totalNum
      }).then(res => {
        if (res == 0 || res < Number(totalNum)) {
          Message.error(`当日剩余可预约作业量${res}万支不足请选择其他到场日期`)
        }
      })
    },
    changeRadio(day) {
      const arr = [dayjs().subtract(day, 'day').format('YYYY-MM-DD') + ' 00:00:00', dayjs().format('YYYY-MM-DD') + ' 23:59:59']
      this.filters.arriveDateStart = arr[0]
      this.filters.arriveDateEnd = arr[1]
      this.getList(1)
    },
    changeForm(str) {
      if (this.filters.arriveDateStart > this.filters.arriveDateEnd) {
        this.filters.arriveDateStart = this.filters.arriveDateEnd
        return this.$message.error('开始时间不能大于结束时间')
      }
      this.getList()
    },
    getList(page) {
      const { pagination, filters } = this
      this.loading = true
      platformBooksPage({
        model: {
          ...filters
        },
        capacity: pagination.pageSize,
        page: page || pagination.page
      }).then(res => {
        this.loading = false
        this.list = res.records || []
        this.list.forEach(item => {
          item.inTypeTemp = item.inType == 0 ? '整托盘' : '件烟'
        })
        this.pagination.total = res.total || 0
      }, () => {
        this.loading = false
      })
    },
    handleEx() {
      this.$dialog.exportConfirm('确认导出吗?')
        .then(() => {
          const { filters } = this
          this.exLoading = true
          platformBooksExport({
            page: this.pagination.page,
            capacity: 1000000,
            model: {
              ...filters
            }
          })
            .then(response => {
              this.download(response)
            })
            .catch(e => {
              this.$tip.apiFailed(e)
            })
            .finally(() => {
              this.exLoading = false
            })
        })
    },
    onSubmit() {
      this.$refs.ruleForm.validate((valid) => {
        const param = this.param
        param.inReason = this.reasonList.find(item => param.reasonId == item.id).reason
        if (valid) {
          this.subLoading = true
          platformBooksApply({ ...param }).then(res => {
            this.getList()
            this.subLoading = false
            this.isShowEdit = false
          }, () => {
            this.subLoading = false
          })
        }
      })
    },
    uploadSuccess(file) {
      this.$set(this.param, 'transportImg', file.imgurl)
      this.$set(this.param, 'transportImgFull', file.imgurlfull)
    },
    handleEdit(row) {
      this.isShowEdit = true
      this.param = {
        inType: 0
      }
      this.$nextTick(() => {
        this.$refs.ruleForm.clearValidate()
      })
      this.$set(this.param, 'arriveDate', dayjs().format('YYYY-MM-DD HH:mm:ss'))
      this.getplatformReason()
    },
    getplatformReason() {
      platformReasonList().then(res => {
        this.reasonList = res || []
      })
    },
    getplatformReasons() {
      platformReasonList().then(res => {
        this.queryFormConfig.formItems[4].options = (res || []).map(item => {
          return {
            value: item.id,
            label: item.reason
          }
        })
      })
    },
    handleSub() {
      this.$refs.ruleForm.validate((valid) => {
        if (valid) {
          alert('submit!')
        }
      })
    },
    clear() {
      this.pagination.page = 1
      this.filters = {}
      this.getList()
      // this.changeRadio('0')
    },
    handleDetail(row) {
      this.isShowDriver = true
      this.$nextTick(() => {
        this.$refs.DriverDetailRef.id = row.id
        this.$refs.DriverDetailRef.type = 6
        this.$refs.DriverDetailRef.getDetail()
        this.$refs.DriverDetailRef.isShowModal = true
      })
    },
    handleDel(row) {
      this.$confirm('确定删除该记录吗, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        deletebooksById(row.id)
          .then(res => {
            this.$message.success('操作成功')
            this.page = 1
            this.getList()
          })
      }).catch(() => {
      })
    },
    handleSizeChange(capacity) {
      this.pagination.pageSize = capacity
      this.getList(1)
    }
  }
}
</script>
<style lang="scss" scoped>
.param_title {
  font-size: 18px;
  font-weight: 600;
  color: #000000;
  margin-bottom: 15px;
}
</style>