taker_list.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. <template>
  2. <div class="app-container">
  3. <!-- 筛选条件 -->
  4. <div>
  5. <el-form
  6. ref="searchForm"
  7. :model="searchForm"
  8. label-width="100px"
  9. size="small"
  10. label-position="left"
  11. >
  12. <el-row :gutter="20">
  13. <el-col :xs="24" :sm="12" :lg="6">
  14. <el-form-item label="经销商名称" prop="customerName">
  15. <el-input
  16. v-model="searchForm.customerName"
  17. placeholder="请输入经销商名称"
  18. ></el-input>
  19. </el-form-item>
  20. </el-col>
  21. <el-col :xs="24" :sm="12" :lg="6">
  22. <el-form-item label="提货人姓名" prop="takerName">
  23. <el-input
  24. v-model="searchForm.takerName"
  25. placeholder="请输入提货人姓名"
  26. ></el-input>
  27. </el-form-item>
  28. </el-col>
  29. <el-col :xs="24" :sm="12" :lg="6">
  30. <el-form-item label="电话" prop="phoneKeyword">
  31. <el-input
  32. v-model="searchForm.phoneKeyword"
  33. placeholder="请输入电话"
  34. ></el-input>
  35. </el-form-item>
  36. </el-col>
  37. <el-col :xs="24" :sm="12" :lg="6" class="tr">
  38. <el-form-item label="">
  39. <el-button size="small" @click="clearFn">清空</el-button>
  40. <el-button size="small" type="primary" @click="searchFn"
  41. >搜索</el-button
  42. >
  43. </el-form-item>
  44. </el-col>
  45. </el-row>
  46. </el-form>
  47. </div>
  48. <!-- 按钮 -->
  49. <div class="btn-group clearfix">
  50. <div class="fl">
  51. <el-button
  52. v-if="$checkBtnRole('add', $router.meta.roles)"
  53. type="primary"
  54. size="small"
  55. @click="addFn"
  56. >新增</el-button
  57. >
  58. </div>
  59. <div class="fr">
  60. <ExportButton :exUrl="'/taker-record/export'" :exParams="exParams" />
  61. </div>
  62. </div>
  63. <!-- 列表 -->
  64. <div class="mymain-container">
  65. <div class="table">
  66. <el-table
  67. v-loading="listLoading"
  68. :data="dataList"
  69. element-loading-text="Loading"
  70. border
  71. fit
  72. highlight-current-row
  73. stripe
  74. >
  75. <el-table-column
  76. align="center"
  77. label="经销商名称"
  78. prop="customerName"
  79. min-width="160"
  80. show-overflow-tooltip
  81. ></el-table-column>
  82. <el-table-column
  83. align="center"
  84. label="提货人姓名"
  85. prop="takerName"
  86. min-width="160"
  87. show-overflow-tooltip
  88. ></el-table-column>
  89. <el-table-column
  90. align="center"
  91. label="身份证"
  92. prop="identity"
  93. min-width="160"
  94. show-overflow-tooltip
  95. ></el-table-column>
  96. <el-table-column
  97. align="center"
  98. label="联系电话"
  99. prop="phone"
  100. min-width="160"
  101. show-overflow-tooltip
  102. ></el-table-column>
  103. <el-table-column
  104. align="center"
  105. label="备用电话"
  106. prop="sparePhone"
  107. min-width="160"
  108. show-overflow-tooltip
  109. ></el-table-column>
  110. <el-table-column
  111. align="center"
  112. label="有效期"
  113. prop="expireTime"
  114. min-width="160"
  115. show-overflow-tooltip
  116. ></el-table-column>
  117. <el-table-column
  118. align="center"
  119. label="创建人"
  120. prop="createBy"
  121. min-width="160"
  122. show-overflow-tooltip
  123. ></el-table-column>
  124. <el-table-column
  125. align="center"
  126. label="创建时间"
  127. prop="createTime"
  128. min-width="160"
  129. show-overflow-tooltip
  130. ></el-table-column>
  131. <el-table-column
  132. align="center"
  133. label="状态"
  134. prop="flag"
  135. min-width="160"
  136. show-overflow-tooltip
  137. >
  138. <template slot-scope="scope">
  139. <el-tag type="success" v-if="scope.row.flag === 1">有效</el-tag>
  140. <el-tag type="danger" v-else-if="scope.row.flag === 2"
  141. >失效</el-tag
  142. >
  143. </template>
  144. </el-table-column>
  145. <el-table-column
  146. align="center"
  147. label="操作"
  148. prop="caozuo"
  149. min-width="160"
  150. show-overflow-tooltip
  151. >
  152. <template slot-scope="scope"
  153. ><el-button
  154. type="text"
  155. class="textColor"
  156. @click="seeFn(scope.row)"
  157. >查看</el-button
  158. >
  159. <el-popconfirm
  160. @onConfirm="deleFn(scope.row.id)"
  161. title="这是一段内容确定删除吗?"
  162. >
  163. <el-button type="text" class="textColor" slot="reference"
  164. >删除</el-button
  165. >
  166. </el-popconfirm>
  167. <el-button
  168. type="text"
  169. class="textColor"
  170. @click="stopFn(scope.row.id)"
  171. v-if="scope.row.flag === 1"
  172. >停用</el-button
  173. >
  174. <el-button
  175. type="text"
  176. class="textColor"
  177. @click="rebuild(scope.row)"
  178. v-else-if="scope.row.flag === 2"
  179. >重建</el-button
  180. >
  181. </template>
  182. </el-table-column>
  183. </el-table>
  184. </div>
  185. <!-- 分页 -->
  186. <div class="fr">
  187. <el-pagination
  188. @size-change="handleSizeChange"
  189. @current-change="handleCurrentChange"
  190. :current-page="currentPage"
  191. :page-sizes="[10, 20, 30, 50]"
  192. :page-size="10"
  193. layout="total, sizes, prev, pager, next, jumper"
  194. :total="listTotal"
  195. >
  196. </el-pagination>
  197. </div>
  198. </div>
  199. <!-- 弹窗 -->
  200. <el-dialog
  201. title="提货人档案"
  202. :visible.sync="dialogForm"
  203. width="40%"
  204. :show-close="false"
  205. :close-on-click-modal="false"
  206. >
  207. <el-form
  208. ref="addForm"
  209. :rules="rules"
  210. :model="addForm"
  211. label-width="120px"
  212. >
  213. <el-form-item label="经销商名称" prop="customerId">
  214. <!-- <el-select v-model="addForm.customerId" placeholder="名称">
  215. <el-option
  216. v-for="item in dealerList"
  217. :key="item.id"
  218. :label="item.name"
  219. :value="item.id"
  220. >
  221. </el-option>
  222. </el-select> -->
  223. <el-input disabled v-model="addForm.customerName"></el-input>
  224. </el-form-item>
  225. <el-row>
  226. <el-col :span="12">
  227. <el-form-item label="提货人姓名" prop="takerName">
  228. <el-input v-model="addForm.takerName"></el-input> </el-form-item
  229. ></el-col>
  230. <el-col :span="12">
  231. <el-form-item label="身份证号码" prop="identity">
  232. <el-input v-model="addForm.identity"></el-input> </el-form-item
  233. ></el-col>
  234. </el-row>
  235. <el-row>
  236. <el-col :span="12">
  237. <el-form-item label="联系电话" prop="phone">
  238. <el-input v-model="addForm.phone"></el-input> </el-form-item
  239. ></el-col>
  240. <el-col :span="12">
  241. <el-row :gutter="0">
  242. <el-col :span="14">
  243. <el-form-item label="验证码" prop="code">
  244. <el-input v-model="addForm.code" />
  245. </el-form-item>
  246. </el-col>
  247. <el-col :span="9">
  248. <el-button v-show="show" type="info" @click="getCodeFn"
  249. >获取验证码</el-button
  250. >
  251. <el-button
  252. v-show="!show"
  253. :style="{
  254. backgroundColor: '#409eff',
  255. border: '0',
  256. }"
  257. type="info"
  258. >{{ count }}s后重新获取</el-button
  259. >
  260. </el-col>
  261. </el-row>
  262. </el-col>
  263. </el-row>
  264. <el-row>
  265. <el-col :span="12">
  266. <el-form-item label="有效期" prop="expireTime">
  267. <el-date-picker
  268. v-model="addForm.expireTime"
  269. type="date"
  270. placeholder="选择日期"
  271. format="yyyy 年 MM 月 dd 日"
  272. value-format="yyyy-MM-dd"
  273. >
  274. </el-date-picker> </el-form-item
  275. ></el-col>
  276. <el-col :span="12">
  277. <el-form-item label="备用电话" prop="sparePhone">
  278. <el-input v-model="addForm.sparePhone"></el-input> </el-form-item
  279. ></el-col>
  280. </el-row>
  281. <el-form-item label="上传提货人附件" prop="fileUrl">
  282. <fileUpload :fileList="fileList" />
  283. </el-form-item>
  284. </el-form>
  285. <div slot="footer" class="dialog-footer">
  286. <el-button @click="cancelFn">取 消</el-button>
  287. <el-button v-if="showOK" type="primary" @click="addDataFn"
  288. >确 定</el-button
  289. >
  290. </div>
  291. </el-dialog>
  292. </div>
  293. </template>
  294. <script>
  295. import { mapGetters } from "vuex";
  296. import {
  297. getList,
  298. addDataList,
  299. getCodeApi,
  300. stopTaker,
  301. deleDataList,
  302. } from "@/api/basic_data/taker";
  303. import { getDealerList } from "@/api/basic_data/dealer";
  304. import { downloadFiles } from "@/utils/util";
  305. import fileUpload from "@/components/Common/file-upload.vue";
  306. export default {
  307. components: {
  308. fileUpload,
  309. },
  310. computed: {
  311. ...mapGetters(["customerId", "customerName"]),
  312. exParams() {
  313. return {
  314. customerName: this.searchForm.customerName,
  315. takerName: this.searchForm.takerName,
  316. phoneKeyword: this.searchForm.phoneKeyword,
  317. };
  318. },
  319. },
  320. data() {
  321. return {
  322. baseURL: process.env.VUE_APP_BASE_API,
  323. fileList: [],
  324. listLoading: false, // 列表加载loading
  325. currentPage: 1, // 当前页码
  326. pageSize: 10, // 每页数量
  327. listTotal: 0, // 列表总数
  328. addForm: {
  329. customerName: "",
  330. takerName: "",
  331. identity: "",
  332. phone: "",
  333. sparePhone: "",
  334. expireTime: "",
  335. code: "",
  336. },
  337. show: true, //验证码
  338. count: "",
  339. timer: null,
  340. rules: {
  341. customerId: [
  342. { required: false, message: "请选择经销商", trigger: "blur" },
  343. ],
  344. takerName: [
  345. { required: true, message: "请输入提货人姓名", trigger: "blur" },
  346. ],
  347. identity: [
  348. {
  349. required: true,
  350. message: "请输入身份证号码",
  351. trigger: "blur",
  352. },
  353. {
  354. pattern:
  355. /^([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]$/,
  356. message: "身份证号格式不正确",
  357. trigger: "blur",
  358. },
  359. ],
  360. phone: [
  361. {
  362. required: true,
  363. message: "请输入联系电话",
  364. trigger: "blur",
  365. },
  366. {
  367. required: true,
  368. pattern:
  369. /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/,
  370. message: "联系电话格式不正确",
  371. trigger: "blur",
  372. },
  373. ],
  374. sparePhone: [
  375. {
  376. required: false,
  377. pattern:
  378. /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/,
  379. message: "请输入备用电话",
  380. trigger: "blur",
  381. },
  382. ],
  383. expireTime: [
  384. { required: true, message: "有效期不能为空", trigger: "blur" },
  385. ],
  386. code: [{ required: true, message: "验证码不能为空", trigger: "blur" }],
  387. },
  388. dialogForm: false,
  389. dataList: [],
  390. searchForm: {
  391. customerName: "",
  392. takerName: "",
  393. phoneKeyword: "",
  394. },
  395. dealerList: [],
  396. id: "", //重建之前的Id
  397. showOK: true,
  398. };
  399. },
  400. async created() {
  401. await this.getDataList({ pageNum: 1, pageSize: 10 });
  402. // await this.getDealerDataList({ pageNum: 1, pageSize: 10 });
  403. },
  404. methods: {
  405. //重建
  406. rebuild(data) {
  407. this.showOK = true;
  408. this.id = data.id;
  409. this.addForm = {
  410. customerName: data.customerName,
  411. takerName: data.takerName,
  412. identity: data.identity,
  413. phone: data.phone,
  414. sparePhone: data.sparePhone,
  415. expireTime: "",
  416. code: "",
  417. };
  418. this.fileList = [];
  419. this.dialogForm = true;
  420. },
  421. //删除
  422. async deleFn(ids) {
  423. await deleDataList({ ids });
  424. this.$message.success("删除成功");
  425. this.getDataList({ pageNum: 1, pageSize: 10 });
  426. },
  427. //查看
  428. seeFn(data) {
  429. this.showOK = false;
  430. this.addForm = data;
  431. this.fileList = [];
  432. this.dialogForm = true;
  433. },
  434. //取消
  435. cancelFn() {
  436. if (this.addForm.id) {
  437. this.addForm = {
  438. takerName: "",
  439. identity: "",
  440. phone: "",
  441. sparePhone: "",
  442. expireTime: "",
  443. code: "",
  444. };
  445. } else {
  446. this.$refs.addForm.resetFields();
  447. }
  448. this.count = 0;
  449. this.dialogForm = false;
  450. },
  451. //上传
  452. handlefile(response, file, fileList) {
  453. console.log(response, file, fileList);
  454. },
  455. // //导出
  456. // exportFn() {
  457. // let screenData = {
  458. // customerName: this.searchForm.customerName,
  459. // takerName: this.searchForm.takerName,
  460. // };
  461. // downloadFiles("/taker-record/export", screenData);
  462. // },
  463. //停用提货人档案
  464. async stopFn(id) {
  465. await stopTaker({ id });
  466. this.$message.success("成功");
  467. this.getDataList({ pageNum: 1, pageSize: this.pageSize });
  468. },
  469. //获取验证码
  470. async getCodeFn() {
  471. const res = await getCodeApi({ mobile: this.addForm.phone });
  472. const TIME_COUNT = 60; //倒计时的初始值
  473. this.count = TIME_COUNT;
  474. this.show = false;
  475. this.timer = setInterval(() => {
  476. if (this.count > 0 && this.count <= TIME_COUNT) {
  477. this.count--;
  478. } else {
  479. this.show = true;
  480. clearInterval(this.timer);
  481. this.timer = null;
  482. }
  483. }, 1000);
  484. },
  485. //获取经销商数据
  486. async getDealerDataList(data) {
  487. const res = await getDealerList(data);
  488. this.dealerList = res.data.records;
  489. },
  490. //获取列表数据
  491. async getDataList(data) {
  492. let res = await getList(data);
  493. console.log(res);
  494. this.dataList = res.data.records;
  495. this.listTotal = res.data.total;
  496. },
  497. //搜索功能
  498. async searchFn() {
  499. console.log(this.searchForm);
  500. await this.getDataList({ ...this.searchForm, pageNum: 1, pageSize: 10 });
  501. },
  502. //重置
  503. clearFn() {
  504. console.log(this.$refs.searchForm);
  505. this.$refs.searchForm.resetFields();
  506. },
  507. // 更改每页数量
  508. handleSizeChange(val) {
  509. this.pageSize = val;
  510. this.currentPage = 1;
  511. this.getDataList({ pageNum: 1, pageSize: this.pageSize });
  512. },
  513. // 更改当前页
  514. handleCurrentChange(val) {
  515. this.currentPage = val;
  516. this.getDataList({ pageNum: val, pageSize: 10 });
  517. },
  518. //新增
  519. async addDataFn() {
  520. console.log(this.fileList);
  521. await this.$refs.addForm.validate();
  522. // const res = this.dealerList.filter(
  523. // (v) => v.id === this.addForm.customerId
  524. // )[0];
  525. // console.log(res);
  526. if (this.fileList.length == 1) {
  527. await addDataList({
  528. ...this.addForm,
  529. customerId: this.customerId,
  530. fileName: this.fileList[0].name,
  531. fileUrl: this.fileList[0].url,
  532. });
  533. } else {
  534. await addDataList({
  535. ...this.addForm,
  536. customerId: this.customerId,
  537. fileName: "",
  538. fileUrl: "",
  539. });
  540. }
  541. if (this.id) {
  542. await deleDataList({ ids: this.id });
  543. }
  544. this.$message.success("新增成功");
  545. this.id = "";
  546. // this.addForm = {
  547. // customerId: "",
  548. // takerName: "",
  549. // identity: "",
  550. // phone: "",
  551. // sparePhone: "",
  552. // expireTime: "",
  553. // code: "",
  554. // };
  555. this.count = 0;
  556. this.getDataList({ pageNum: 1, pageSize: 10 });
  557. this.dialogForm = false;
  558. },
  559. addFn() {
  560. this.addForm = {
  561. customerName: this.customerName,
  562. takerName: "",
  563. identity: "",
  564. phone: "",
  565. sparePhone: "",
  566. expireTime: "",
  567. code: "",
  568. };
  569. this.fileList = [];
  570. this.showOK = true;
  571. this.dialogForm = true;
  572. },
  573. },
  574. };
  575. </script>
  576. <style lang="scss" scoped>
  577. ::v-deep .el-date-editor {
  578. width: 100%;
  579. }
  580. ::v-deep .el-select {
  581. width: 100%;
  582. }
  583. ::v-deep .el-col-9 .el-button {
  584. padding: 5px;
  585. margin: 6px;
  586. }
  587. ::v-deep .el-dialog__header {
  588. background-color: #dddddd;
  589. }
  590. .base {
  591. padding: 20px 20px 0;
  592. }
  593. .table {
  594. margin-top: 12px;
  595. }
  596. .right {
  597. float: right;
  598. }
  599. </style>