taker_list.vue 16 KB

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