123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429 |
- <template>
- <div class="app-container">
- <!-- 筛选条件 -->
- <div>
- <el-form
- :model="searchForm"
- ref="searchForm"
- label-width="100px"
- size="small"
- label-position="left"
- >
- <el-row :gutter="20">
- <el-col :xs="24" :sm="12" :lg="6">
- <el-form-item label="经销商名称" prop="customerName">
- <el-input
- v-model="searchForm.customerName"
- placeholder="请输入经销商名称"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="6">
- <el-form-item label="车牌" prop="carBrand">
- <el-input
- v-model="searchForm.carBrand"
- placeholder="请输入车牌"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="12" class="tr">
- <el-form-item label="">
- <el-button size="small" @click="clearFn">清空</el-button>
- <el-button size="small" type="primary" @click="searchFn"
- >搜索</el-button
- >
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- </div>
- <!-- 按钮 -->
- <div class="btn-group clearfix">
- <div class="fl">
- <el-button type="primary" size="small" @click="addDataList"
- >新增</el-button
- >
- <el-popconfirm @onConfirm="delFn" title="这是一段内容确定删除吗?">
- <el-button
- size="small"
- type="primary"
- class="textColor"
- slot="reference"
- >删除</el-button
- >
- </el-popconfirm>
- </div>
- <div class="fr">
- <el-button type="primary" size="small" @click="exportFn"
- >导出</el-button
- >
- </div>
- </div>
- <!-- 列表 -->
- <div class="mymain-container">
- <div class="table">
- <el-table
- v-loading="listLoading"
- :data="dataList"
- element-loading-text="Loading"
- @select="hanleSelect"
- @select-all="hanleSelect"
- border
- fit
- highlight-current-row
- stripe
- >
- <el-table-column
- type="selection"
- align="center"
- min-width="100"
- ></el-table-column>
- <el-table-column
- align="center"
- label="经销商名称"
- prop="customerName"
- min-width="160"
- show-overflow-tooltip
- ></el-table-column>
- <el-table-column
- align="center"
- label="车辆车牌号"
- prop="carBrand"
- min-width="160"
- show-overflow-tooltip
- ></el-table-column>
- <el-table-column
- align="center"
- label="创建者"
- prop="createBy"
- min-width="160"
- show-overflow-tooltip
- ></el-table-column>
- <el-table-column
- align="center"
- label="创建时间"
- prop="createTime"
- min-width="160"
- show-overflow-tooltip
- ></el-table-column>
- <el-table-column
- align="center"
- label="更新者"
- prop="updateBy"
- min-width="160"
- show-overflow-tooltip
- ></el-table-column>
- <el-table-column
- align="center"
- label="更新时间"
- prop="updateTime"
- min-width="160"
- show-overflow-tooltip
- ></el-table-column>
- <el-table-column
- align="center"
- label="操作"
- min-width="160"
- show-overflow-tooltip
- >
- <template slot-scope="scope">
- <el-button
- type="text"
- class="textColor"
- @click="editFn(scope.row)"
- >编辑</el-button
- >
- <el-popconfirm
- @onConfirm="delFn(scope.row.id)"
- title="这是一段内容确定删除吗?"
- >
- <el-button type="text" class="textColor" slot="reference"
- >删除</el-button
- >
- </el-popconfirm>
- </template>
- </el-table-column>
- </el-table>
- </div>
- <!-- 分页 -->
- <div class="fr">
- <el-pagination
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- :current-page="currentPage"
- :page-sizes="[10, 20, 30, 50]"
- :page-size="10"
- layout="total, sizes, prev, pager, next, jumper"
- :total="listTotal"
- >
- </el-pagination>
- </div>
- </div>
- <!-- 弹窗 -->
- <el-dialog
- title="提货车辆档案"
- :visible.sync="dialogForm"
- width="40%"
- :show-close="false"
- :close-on-click-modal="false"
- >
- <el-form
- ref="addForm"
- :rules="rules"
- :model="addForm"
- label-width="120px"
- class="demo-ruleForm"
- >
- <el-form-item label="经销商名称" prop="customerId">
- <el-select
- v-model="addForm.customerId"
- placeholder="请选择经销商名称"
- >
- <el-option
- v-for="item in dealerList"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- >
- </el-option>
- </el-select>
- </el-form-item>
- <el-row>
- <el-col :span="12">
- <el-form-item label="车牌号" prop="carBrand">
- <el-input v-model="addForm.carBrand"></el-input> </el-form-item
- ></el-col>
- <el-col :span="12">
- <el-form-item label="联系电话" prop="mobile">
- <el-input v-model="addForm.mobile"></el-input> </el-form-item
- ></el-col>
- </el-row>
- <el-row>
- <el-col :span="12">
- <el-form-item label="车型" prop="carType">
- <el-input v-model="addForm.carType"></el-input> </el-form-item
- ></el-col>
- <el-col :span="12">
- <el-form-item label="体积" prop="volume">
- <el-input v-model="addForm.volume">
- <i class="el-input__icon" slot="suffix">m³ </i>
- </el-input>
- </el-form-item></el-col
- >
- </el-row>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button @click="cancelFn">取 消</el-button>
- <el-button type="primary" @click="addDataListFn">确 定</el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import {
- getCarList,
- addDataListApi,
- delCarFn,
- editDataListApi,
- } from "@/api/basic_data/taker";
- import { getDealerList } from "@/api/basic_data/dealer";
- import { downloadFiles } from "@/utils/util";
- export default {
- data() {
- return {
- listLoading: false, // 列表加载loading
- currentPage: 1, // 当前页码
- pageSize: 10, // 每页数量
- listTotal: 0, // 列表总数
- addForm: {
- customerId: "",
- mobile: "",
- carType: "",
- volume: "",
- carBrand: "",
- },
- rules: {
- customerId: [
- { required: true, message: "请选择活动区域", trigger: "blur" },
- ],
- mobile: [
- {
- required: true,
- message: "请输入联系电话",
- trigger: "blur",
- },
- {
- required: true,
- pattern:
- /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/,
- message: "联系电话格式不正确",
- trigger: "blur",
- },
- ],
- // carType: [{ required: true, message: "车型不能为空", trigger: "blur" }],
- // volume: [{ required: true, message: "体积不能为空", trigger: "blur" }],
- carBrand: [
- { required: true, message: "车牌号不能为空", trigger: "blur" },
- ],
- },
- dialogForm: false,
- dataList: [],
- searchForm: {
- customerName: "",
- carBrand: "",
- },
- dealerList: [],
- ids: [],
- };
- },
- async created() {
- this.getDataList({ pageNum: 1, pageSize: 10 });
- },
- methods: {
- // 筛选部分数据或者单个
- hanleSelect(selection) {
- // this.ids = selection.map((k) => {
- // return k.id;
- // });
- console.log(selection);
- this.ids = selection.map((v) => v.id);
- console.log(this.ids);
- },
- //导出
- exportFn() {
- let screenData = {
- customerName: this.searchForm.customerName,
- carBrand: this.searchForm.carBrand,
- };
- downloadFiles("/take-car-record/export", screenData);
- },
- //取消
- async cancelFn() {
- this.addForm = {
- customerId: "",
- mobile: "",
- carType: "",
- volume: "",
- carBrand: "",
- };
- await this.$refs.addForm.resetFields();
- this.dialogForm = false;
- },
- //编辑
- editFn(data) {
- this.dialogForm = true;
- this.addForm = data;
- },
- //重置
- clearFn() {
- console.log(this.$refs.searchForm);
- this.$refs.searchForm.resetFields();
- },
- //搜索
- async searchFn() {
- console.log(this.searchForm);
- await this.getDataList({
- ...this.searchForm,
- pageNum: 1,
- pageSize: this.pageSize,
- });
- },
- //删除
- async delFn(ids) {
- this.ids.push(ids);
- let res = this.ids.toString();
- await delCarFn({ ids: res });
- this.$message.success("删除成功");
- this.getDataList({ pageNum: this.currentPage, pageSize: this.pageSize });
- },
- //获取经销商数据
- async getDealerDataList(data) {
- const res = await getDealerList(data);
- this.dealerList = res.data.records;
- },
- //新增
- addDataList() {
- this.addForm = {
- customerId: "",
- mobile: "",
- carType: "",
- volume: "",
- carBrand: "",
- };
- this.dialogForm = true;
- this.getDealerDataList({ pageNum: 1, pageSize: 10 });
- },
- async addDataListFn() {
- await this.$refs.addForm.validate();
- const res = this.dealerList.filter(
- (v) => v.id === this.addForm.customerId
- )[0];
- if (this.addForm.id) {
- await editDataListApi({ ...this.addForm });
- this.$message.success("编辑成功");
- } else {
- await addDataListApi({ ...this.addForm, orgNumber: res.useOrgNumber });
- this.$message.success("添加成功");
- }
- // console.log(res);
- //
- // this.addForm = {
- // customerId: "",
- // mobile: "",
- // carType: "",
- // volume: "",
- // carBrand: "",
- // };
- await this.$refs.addForm.resetFields();
- this.getDataList({ pageNum: this.currentPage, pageSize: this.pageSize });
- this.dialogForm = false;
- },
- //获取列表数据
- async getDataList(data) {
- const res = await getCarList(data);
- console.log(res);
- this.dataList = res.data.records;
- this.listTotal = res.data.total;
- },
- // 更改每页数量
- handleSizeChange(val) {
- this.pageSize = val;
- this.currentPage = 1;
- this.getDataList({ pageNum: 1, pageSize: this.pageSize });
- },
- // 更改当前页
- handleCurrentChange(val) {
- this.currentPage = val;
- this.getDataList({ pageNum: val, pageSize: this.pageSize });
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- ::v-deep .el-popover__reference {
- margin-left: 10px;
- }
- ::v-deep .el-date-editor {
- width: 100%;
- }
- ::v-deep .el-select {
- width: 100%;
- }
- ::v-deep .el-col-9 .el-button {
- padding: 5px;
- }
- ::v-deep .el-dialog__header {
- background-color: #dddddd;
- }
- </style>
|