123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621 |
- <template>
- <div class="app-container">
- <!-- 筛选条件 -->
- <div>
- <el-form
- ref="searchForm"
- :model="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="takerName">
- <el-input
- v-model="searchForm.takerName"
- placeholder="请输入提货人姓名"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="6">
- <el-form-item label="电话" prop="phoneKeyword">
- <el-input
- v-model="searchForm.phoneKeyword"
- placeholder="请输入电话"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="6" 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
- v-if="$checkBtnRole('add', $router.meta.roles)"
- type="primary"
- size="small"
- @click="addFn"
- >新增</el-button
- >
- </div>
- <div class="fr">
- <ExportButton :exUrl="'/taker-record/export'" :exParams="exParams" />
- </div>
- </div>
- <!-- 列表 -->
- <div class="mymain-container">
- <div class="table">
- <el-table
- v-loading="listLoading"
- :data="dataList"
- element-loading-text="Loading"
- border
- fit
- highlight-current-row
- stripe
- >
- <el-table-column
- align="center"
- label="经销商名称"
- prop="customerName"
- min-width="160"
- show-overflow-tooltip
- ></el-table-column>
- <el-table-column
- align="center"
- label="提货人姓名"
- prop="takerName"
- min-width="160"
- show-overflow-tooltip
- ></el-table-column>
- <el-table-column
- align="center"
- label="身份证"
- prop="identity"
- min-width="160"
- show-overflow-tooltip
- ></el-table-column>
- <el-table-column
- align="center"
- label="联系电话"
- prop="phone"
- min-width="160"
- show-overflow-tooltip
- ></el-table-column>
- <el-table-column
- align="center"
- label="备用电话"
- prop="sparePhone"
- min-width="160"
- show-overflow-tooltip
- ></el-table-column>
- <el-table-column
- align="center"
- label="有效期"
- prop="expireTime"
- 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="flag"
- min-width="160"
- show-overflow-tooltip
- >
- <template slot-scope="scope">
- <el-tag type="success" v-if="scope.row.flag === 1">有效</el-tag>
- <el-tag type="danger" v-else-if="scope.row.flag === 2"
- >失效</el-tag
- >
- </template>
- </el-table-column>
- <el-table-column
- align="center"
- label="操作"
- prop="caozuo"
- min-width="160"
- show-overflow-tooltip
- >
- <template slot-scope="scope"
- ><el-button
- type="text"
- class="textColor"
- @click="seeFn(scope.row)"
- >查看</el-button
- >
- <el-popconfirm
- @onConfirm="deleFn(scope.row.id)"
- title="这是一段内容确定删除吗?"
- >
- <el-button type="text" class="textColor" slot="reference"
- >删除</el-button
- >
- </el-popconfirm>
- <el-button
- type="text"
- class="textColor"
- @click="stopFn(scope.row.id)"
- v-if="scope.row.flag === 1"
- >停用</el-button
- >
- <el-button
- type="text"
- class="textColor"
- @click="rebuild(scope.row)"
- v-else-if="scope.row.flag === 2"
- >重建</el-button
- >
- </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"
- >
- <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-input disabled v-model="addForm.customerName"></el-input>
- </el-form-item>
- <el-row>
- <el-col :span="12">
- <el-form-item label="提货人姓名" prop="takerName">
- <el-input v-model="addForm.takerName"></el-input> </el-form-item
- ></el-col>
- <el-col :span="12">
- <el-form-item label="身份证号码" prop="identity">
- <el-input v-model="addForm.identity"></el-input> </el-form-item
- ></el-col>
- </el-row>
- <el-row>
- <el-col :span="12">
- <el-form-item label="联系电话" prop="phone">
- <el-input v-model="addForm.phone"></el-input> </el-form-item
- ></el-col>
- <el-col :span="12">
- <el-row :gutter="0">
- <el-col :span="14">
- <el-form-item label="验证码" prop="code">
- <el-input v-model="addForm.code" />
- </el-form-item>
- </el-col>
- <el-col :span="9">
- <el-button v-show="show" type="info" @click="getCodeFn"
- >获取验证码</el-button
- >
- <el-button
- v-show="!show"
- :style="{
- backgroundColor: '#409eff',
- border: '0',
- }"
- type="info"
- >{{ count }}s后重新获取</el-button
- >
- </el-col>
- </el-row>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="12">
- <el-form-item label="有效期" prop="expireTime">
- <el-date-picker
- v-model="addForm.expireTime"
- type="date"
- placeholder="选择日期"
- format="yyyy 年 MM 月 dd 日"
- value-format="yyyy-MM-dd"
- >
- </el-date-picker> </el-form-item
- ></el-col>
- <el-col :span="12">
- <el-form-item label="备用电话" prop="sparePhone">
- <el-input v-model="addForm.sparePhone"></el-input> </el-form-item
- ></el-col>
- </el-row>
- <el-form-item label="上传提货人附件" prop="fileUrl">
- <fileUpload :fileList="fileList" />
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button @click="cancelFn">取 消</el-button>
- <el-button v-if="showOK" type="primary" @click="addDataFn"
- >确 定</el-button
- >
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import { mapGetters } from "vuex";
- import {
- getList,
- addDataList,
- getCodeApi,
- stopTaker,
- deleDataList,
- } from "@/api/basic_data/taker";
- import { getDealerList } from "@/api/basic_data/dealer";
- import { downloadFiles } from "@/utils/util";
- import fileUpload from "@/components/Common/file-upload.vue";
- export default {
- components: {
- fileUpload,
- },
- computed: {
- ...mapGetters(["customerId", "customerName"]),
- exParams() {
- return {
- customerName: this.searchForm.customerName,
- takerName: this.searchForm.takerName,
- phoneKeyword: this.searchForm.phoneKeyword,
- };
- },
- },
- data() {
- return {
- baseURL: process.env.VUE_APP_BASE_API,
- fileList: [],
- listLoading: false, // 列表加载loading
- currentPage: 1, // 当前页码
- pageSize: 10, // 每页数量
- listTotal: 0, // 列表总数
- addForm: {
- customerName: "",
- takerName: "",
- identity: "",
- phone: "",
- sparePhone: "",
- expireTime: "",
- code: "",
- },
- show: true, //验证码
- count: "",
- timer: null,
- rules: {
- customerId: [
- { required: false, message: "请选择经销商", trigger: "blur" },
- ],
- takerName: [
- { required: true, message: "请输入提货人姓名", trigger: "blur" },
- ],
- identity: [
- {
- required: true,
- message: "请输入身份证号码",
- trigger: "blur",
- },
- {
- pattern:
- /^([1-6][1-9]|50)\d{4}(18|19|20)\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,
- message: "身份证号格式不正确",
- trigger: "blur",
- },
- ],
- phone: [
- {
- 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",
- },
- ],
- sparePhone: [
- {
- required: false,
- 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",
- },
- ],
- expireTime: [
- { required: true, message: "有效期不能为空", trigger: "blur" },
- ],
- code: [{ required: true, message: "验证码不能为空", trigger: "blur" }],
- },
- dialogForm: false,
- dataList: [],
- searchForm: {
- customerName: "",
- takerName: "",
- phoneKeyword: "",
- },
- dealerList: [],
- id: "", //重建之前的Id
- showOK: true,
- };
- },
- async created() {
- await this.getDataList({ pageNum: 1, pageSize: 10 });
- // await this.getDealerDataList({ pageNum: 1, pageSize: 10 });
- },
- methods: {
- //重建
- rebuild(data) {
- this.showOK = true;
- this.id = data.id;
- this.addForm = {
- customerName: data.customerName,
- takerName: data.takerName,
- identity: data.identity,
- phone: data.phone,
- sparePhone: data.sparePhone,
- expireTime: "",
- code: "",
- };
- this.fileList = [];
- this.dialogForm = true;
- },
- //删除
- async deleFn(ids) {
- await deleDataList({ ids });
- this.$message.success("删除成功");
- this.getDataList({ pageNum: 1, pageSize: 10 });
- },
- //查看
- seeFn(data) {
- this.showOK = false;
- this.addForm = data;
- this.fileList = [];
- this.dialogForm = true;
- },
- //取消
- cancelFn() {
- if (this.addForm.id) {
- this.addForm = {
- takerName: "",
- identity: "",
- phone: "",
- sparePhone: "",
- expireTime: "",
- code: "",
- };
- } else {
- this.$refs.addForm.resetFields();
- }
- this.count = 0;
- this.dialogForm = false;
- },
- //上传
- handlefile(response, file, fileList) {
- console.log(response, file, fileList);
- },
- // //导出
- // exportFn() {
- // let screenData = {
- // customerName: this.searchForm.customerName,
- // takerName: this.searchForm.takerName,
- // };
- // downloadFiles("/taker-record/export", screenData);
- // },
- //停用提货人档案
- async stopFn(id) {
- await stopTaker({ id });
- this.$message.success("成功");
- this.getDataList({ pageNum: 1, pageSize: this.pageSize });
- },
- //获取验证码
- async getCodeFn() {
- const res = await getCodeApi({ mobile: this.addForm.phone });
- const TIME_COUNT = 60; //倒计时的初始值
- this.count = TIME_COUNT;
- this.show = false;
- this.timer = setInterval(() => {
- if (this.count > 0 && this.count <= TIME_COUNT) {
- this.count--;
- } else {
- this.show = true;
- clearInterval(this.timer);
- this.timer = null;
- }
- }, 1000);
- },
- //获取经销商数据
- async getDealerDataList(data) {
- const res = await getDealerList(data);
- this.dealerList = res.data.records;
- },
- //获取列表数据
- async getDataList(data) {
- let res = await getList(data);
- console.log(res);
- this.dataList = res.data.records;
- this.listTotal = res.data.total;
- },
- //搜索功能
- async searchFn() {
- console.log(this.searchForm);
- await this.getDataList({ ...this.searchForm, pageNum: 1, pageSize: 10 });
- },
- //重置
- clearFn() {
- console.log(this.$refs.searchForm);
- this.$refs.searchForm.resetFields();
- },
- // 更改每页数量
- 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: 10 });
- },
- //新增
- async addDataFn() {
- console.log(this.fileList);
- await this.$refs.addForm.validate();
- // const res = this.dealerList.filter(
- // (v) => v.id === this.addForm.customerId
- // )[0];
- // console.log(res);
- if (this.fileList.length == 1) {
- await addDataList({
- ...this.addForm,
- customerId: this.customerId,
- fileName: this.fileList[0].name,
- fileUrl: this.fileList[0].url,
- });
- } else {
- await addDataList({
- ...this.addForm,
- customerId: this.customerId,
- fileName: "",
- fileUrl: "",
- });
- }
- if (this.id) {
- await deleDataList({ ids: this.id });
- }
- this.$message.success("新增成功");
- this.id = "";
- // this.addForm = {
- // customerId: "",
- // takerName: "",
- // identity: "",
- // phone: "",
- // sparePhone: "",
- // expireTime: "",
- // code: "",
- // };
- this.count = 0;
- this.getDataList({ pageNum: 1, pageSize: 10 });
- this.dialogForm = false;
- },
- addFn() {
- this.addForm = {
- customerName: this.customerName,
- takerName: "",
- identity: "",
- phone: "",
- sparePhone: "",
- expireTime: "",
- code: "",
- };
- this.fileList = [];
- this.showOK = true;
- this.dialogForm = true;
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- ::v-deep .el-date-editor {
- width: 100%;
- }
- ::v-deep .el-select {
- width: 100%;
- }
- ::v-deep .el-col-9 .el-button {
- padding: 5px;
- margin: 6px;
- }
- ::v-deep .el-dialog__header {
- background-color: #dddddd;
- }
- .base {
- padding: 20px 20px 0;
- }
- .table {
- margin-top: 12px;
- }
- .right {
- float: right;
- }
- </style>
|