index.vue 14.7 KB
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 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="订单 id" prop="garOrderId">
        <el-input
          v-model="queryParams.garOrderId"
          placeholder="请输入订单 id"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="运输驾驶员" prop="garOrderHandlerName">
        <el-input
          v-model="queryParams.garOrderHandlerName"
          placeholder="请输入运输驾驶员"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="车牌号" prop="garHandlerCarCode">
        <el-input
          v-model="queryParams.garHandlerCarCode"
          placeholder="请输入车牌号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="公司名称" prop="garOrderHandlerCompanyName">
        <el-input
          v-model="queryParams.garOrderHandlerCompanyName"
          placeholder="请输入公司名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="投放点" prop="dropPointName">
        <el-input
          v-model="queryParams.dropPointName"
          placeholder="请输入投放点"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="趟次类型" prop="garOrderType">
        <el-select v-model="queryParams.garOrderType" placeholder="请选择趟次类型" clearable size="small">
          <el-option label="全部" value="" />
          <el-option label="正常趟次" value="0" />
          <el-option label="异常趟次" value="1" />
        </el-select>
      </el-form-item>
      <el-form-item label="处理场所" prop="disposalSiteName">
        <el-input
          v-model="queryParams.disposalSiteName"
          placeholder="请输入处理场所"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="订单编号" prop="garOrderNumber">
        <el-input
          v-model="queryParams.garOrderNumber"
          placeholder="请输入订单编号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="下单手机号" prop="garOrderPhone">-->
<!--        <el-input-->
<!--          v-model="queryParams.garOrderPhone"-->
<!--          placeholder="请输入下单人手机号"-->
<!--          clearable-->
<!--          size="small"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="下单人" prop="garOrderName">-->
<!--        <el-input-->
<!--          v-model="queryParams.garOrderName"-->
<!--          placeholder="请输入下单人"-->
<!--          clearable-->
<!--          size="small"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item>
        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="warning"
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['ask:ask:export']"
        >导出</el-button>
      </el-col>
	  <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="askList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="订单编号" align="center" prop="garOrderId" />
      <el-table-column label="联单编号" align="center" prop="garOrderNumber" />
      <el-table-column label="订单生成时间" align="center" prop="garCreateTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.garCreateTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="下单人" align="center" prop="garOrderName" />
      <el-table-column label="运输企业" align="center" prop="garOrderHandlerCompanyName" />
      <el-table-column label="运输驾驶员" align="center" prop="garOrderHandlerName" />
      <el-table-column label="车牌号" align="center" prop="garHandlerCarCode" />
      <el-table-column label="处理场所" align="center" prop="disposalSiteName" />
      <el-table-column label="接收时间" align="center" prop="garUpdateTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.garUpdateTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="车辆载重(吨)" align="center" prop="garCarryingWeight" />
      <el-table-column label="趟次类型" align="center" prop="garOrderType" >
        <template slot-scope="scope">
          <span v-if="scope.row.garOrderType == 0">正常趟次</span>
          <span v-if="scope.row.garOrderType == 1">异常趟次</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            @click="handleUpdate(scope.row)"
          >联单详情</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改趟次关联台账对话框 -->
    <el-dialog
      :title="title"
      :visible.sync="open"
      width="800px"
      ref="myDialog"
      :show-close="false"
      append-to-body
    >

      <div style="overflow-x:auto;" ref="printArea">
        <h1 style="text-align:center;">装修垃圾收运处电子联单</h1>
        <div style="margin-bottom: 10px; font-size: 18px">
          <span>联单编号:<span style="color:red;">{{ form.garOrderNumber }}</span></span>
        </div>
        <table
          border="1"
          cellspacing="0"
          cellpadding="8"
          style="width: 100%; border-collapse: collapse; font-size: 16px; text-align: left;"
        >
          <!-- 投放端信息 分隔 -->
          <tr>
            <td colspan="4" style="background:#f5f7fa; font-weight:600;">
              投放端信息
            </td>
          </tr>
          <tr>
            <td style="width:20%;">投放人名称</td>
            <td style="width:30%;">{{ form.garOrderName || '-' }}</td>
            <td style="width:20%;">订单时间</td>
            <td style="width:30%;">{{ form.garOrderTime || '-' }}</td>
          </tr>
          <tr>
            <td>联系电话</td>
            <td>{{ form.garOrderPhone || '-' }}</td>
            <td>车次</td>
            <td v-if="form.dropCarNum!==0">{{ form.dropCarNum }}/{{ dropCarNum }}</td>
            <td v-if="form.dropCarNum===0">-</td>
          </tr>
          <tr>
            <td>投放地址</td>
            <td colspan="3">{{ form.dropAddress || '-' }}</td>
          </tr>

          <!-- 运输端信息 分隔 -->
          <tr>
            <td colspan="4" style="background:#f5f7fa; font-weight:600;">
              运输端信息
            </td>
          </tr>
          <tr>
            <td>运输单位</td>
            <td>{{ form.garOrderHandlerCompanyName || '-' }}</td>
            <td>运输时间</td>
            <td>{{ form.garCreateTime || '-' }}</td>
          </tr>
          <tr>
            <td>车牌号</td>
            <td>{{ form.garCarCode || '-' }}</td>
            <td>驾驶员</td>
            <td>{{ form.garOrderHandlerName || '-' }}</td>
          </tr>

          <!-- 处置端信息 分隔 -->
          <tr>
            <td colspan="4" style="background:#f5f7fa; font-weight:600;">
              处置端信息
            </td>
          </tr>
          <tr>
            <td>处置场名称</td>
            <td>{{ form.disposalSiteName || '-' }}</td>
            <td>接收时间</td>
            <td>{{ form.garUpdateTime || '-' }}</td>
          </tr>
          <tr>
            <td>接收车牌</td>
            <td>{{ form.garHandlerCarCode || '-' }}</td>
            <td>载重(吨)</td>
            <td>{{ form.garCarryingWeight || '-' }}</td>
          </tr>

          <!-- 备注 -->
          <tr>
            <td>备注</td>
            <td colspan="3">{{ form.garRemark || '-' }}</td>
          </tr>
        </table>
      </div>

      <template #footer>
        <el-button type="primary" @click="handlePrint" v-show="isPrint">打印</el-button>
        <el-button type="primary" @click="exportToPDF" v-show="isPrint">导出</el-button>
        <el-button @click="cancel" v-show="isPrint">取 消</el-button>
      </template>
    </el-dialog>
  </div>
</template>

<script>
import { listAsk, getAsk, delAsk, addAsk, updateAsk, exportAsk } from "@/api/ask/ask";
import html2pdf from 'html2pdf.js'

export default {
  name: "Ask",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 趟次关联台账表格数据
      askList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        garOrderId: null,
        garOrderHandlerTel: null,
        garOrderHandlerName: null,
        garOrderContainerVolume: null,
        garOrderHandlerId: null,
        garHandlerCarCode: null,
        garOrderHandlerCompanyId: null,
        garOrderHandlerCompanyName: null,
        garCreateTime: null,
        garUpdateTime: null,
        garCreateBy: null,
        garUpdateBy: null,
        garRemark: null,
        garCarryingWeight: null,
        dropPointId: null,
        dropPointName: null,
        garOrderType: null,
        disposalId: null,
        disposalSiteName: null,
        garOrderNumber: null,
        garOrderPhone: null,
        garOrderName: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      },
      isPrint: false,
      dropCarNum: 0
    };
  },
  created() {
    this.getList();
  },
  methods: {
    exportToPDF() {
      const element = this.$refs.printArea;

      const opt = {
        margin:       [0.4, 0.2],        // 上下、左右 页边距(单位:inch)
        filename:     `装修垃圾收运处电子联单_${this.form.garOrderNumber}.pdf`,
        image:        { type: 'jpeg', quality: 0.98 },
        html2canvas:  { scale: 2, useCORS: true },
        jsPDF:        { unit: 'in', format: 'a4', orientation: 'portrait' }
      };

      // 调用 html2pdf,自动生成并下载
      html2pdf()
        .set(opt)
        .from(element)
        .save()
        .catch(err => {
          console.error('导出 PDF 失败:', err);
        });
    },
    handlePrint() {
      // 先关闭 el-dialog 的 modal 遮罩,防止遮罩也一起打印
      this.$refs.myDialog.hide();
      this.isPrint = false;
      // 等 Vue 更新完后再调用
      this.$nextTick(() => {
        window.print();
        this.isPrint = true;
      });
    },
    /** 查询趟次关联台账列表 */
    getList() {
      this.loading = true;
      listAsk(this.queryParams).then(response => {
        this.askList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        garId: null,
        garOrderId: null,
        garOrderHandlerTel: null,
        garOrderHandlerName: null,
        garOrderContainerVolume: null,
        garOrderHandlerId: null,
        garHandlerCarCode: null,
        garOrderHandlerCompanyId: null,
        garOrderHandlerCompanyName: null,
        garCreateTime: null,
        garUpdateTime: null,
        garCreateBy: null,
        garUpdateBy: null,
        garRemark: null,
        garCarryingWeight: null,
        dropPointId: null,
        dropPointName: null,
        garOrderType: null,
        disposalId: null,
        disposalSiteName: null,
        garOrderNumber: null,
        garOrderPhone: null,
        garOrderName: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.garId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      this.dropCarNum = 0;
      const garId = row.garId || this.ids
      listAsk({"garOrderId":row.garOrderId}).then(response => {
        this.dropCarNum = response.total;
      });
      getAsk(garId).then(response => {
        this.form = response.data;
        this.open = true;
        this.isPrint = true;
        this.title = "";
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有趟次关联台账数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportAsk(queryParams);
        }).then(response => {
          this.download(response.message);
        })
    }
  }
};
</script>
<style lang="scss" scoped>
.table-container {
  overflow-x: auto;
  padding: 16px;
  background: #fff;
  table {
    width: 100%;
    border-collapse: collapse;
    th, td {
      border: 1px solid #333;
      padding: 8px;
      vertical-align: middle;
      font-size: 14px;
    }
    th {
      background: #f0f0f0;
      font-weight: 600;
    }
    tr:nth-of-type(3),
    tr:nth-of-type(6),
    tr:nth-of-type(9) {
      td {
        background: #fafafa;
        font-weight: 600;
      }
    }
  }
}
</style>