taker_list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. <template>
  2. <template-page
  3. ref="pageRef"
  4. :getList="getList"
  5. :operation="operation()"
  6. :optionsEvensGroup="optionsEvensGroup"
  7. :exportList="exportList"
  8. :columnParsing="columnParsing"
  9. :tableAttributes="tableAttributes"
  10. :tableEvents="tableEvents"
  11. :operationColumnWidth="200"
  12. :replaceOrNotMap="false"
  13. >
  14. <!-- 弹窗 -->
  15. <el-dialog
  16. title="提货人档案"
  17. :visible.sync="dialogForm"
  18. width="40%"
  19. :show-close="false"
  20. :close-on-click-modal="false"
  21. >
  22. <el-form ref="addForm" :rules="rules" :model="addForm" label-width="120px">
  23. <el-form-item label="经销商名称" prop="customerId">
  24. <!-- <el-select v-model="addForm.customerId" placeholder="名称">
  25. <el-option
  26. v-for="item in dealerList"
  27. :key="item.id"
  28. :label="item.name"
  29. :value="item.id"
  30. >
  31. </el-option>
  32. </el-select> -->
  33. <el-input disabled v-model="addForm.customerName"></el-input>
  34. </el-form-item>
  35. <el-row>
  36. <el-col :span="12">
  37. <el-form-item label="提货人姓名" prop="takerName">
  38. <el-input v-model="addForm.takerName"></el-input>
  39. </el-form-item>
  40. </el-col>
  41. <el-col :span="12">
  42. <el-form-item label="身份证号码" prop="identity">
  43. <el-input v-model="addForm.identity"></el-input>
  44. </el-form-item>
  45. </el-col>
  46. </el-row>
  47. <el-row>
  48. <el-col :span="12">
  49. <el-form-item label="联系电话" prop="phone">
  50. <el-input v-model="addForm.phone"></el-input>
  51. </el-form-item>
  52. </el-col>
  53. <!-- <el-col :span="12">
  54. <el-row :gutter="0">
  55. <el-col :span="14">
  56. <el-form-item label="验证码" prop="code">
  57. <el-input v-model="addForm.code" />
  58. </el-form-item>
  59. </el-col>
  60. <el-col :span="9">
  61. <el-button v-show="show" type="info" @click="getCodeFn">获取验证码</el-button>
  62. <el-button v-show="!show" :style="{
  63. backgroundColor: '#409eff',
  64. border: '0',
  65. }" type="info">{{ count }}s后重新获取</el-button>
  66. </el-col>
  67. </el-row>
  68. </el-col> -->
  69. </el-row>
  70. <el-row>
  71. <el-col :span="12">
  72. <el-form-item label="有效期" prop="expireTime">
  73. <el-date-picker
  74. v-model="addForm.expireTime"
  75. type="date"
  76. placeholder="选择日期"
  77. format="yyyy 年 MM 月 dd 日"
  78. value-format="yyyy-MM-dd"
  79. >
  80. </el-date-picker>
  81. </el-form-item>
  82. </el-col>
  83. <el-col :span="12">
  84. <el-form-item label="备用电话" prop="sparePhone">
  85. <el-input v-model="addForm.sparePhone"></el-input>
  86. </el-form-item>
  87. </el-col>
  88. </el-row>
  89. <el-form-item label="上传提货人附件" prop="fileUrl">
  90. <fileUpload :fileList="fileList" />
  91. </el-form-item>
  92. </el-form>
  93. <div slot="footer" class="dialog-footer">
  94. <el-button @click="cancelFn">取 消</el-button>
  95. <el-button v-if="showOK" type="primary" @click="addDataFn">确 定</el-button>
  96. </div>
  97. </el-dialog>
  98. </template-page>
  99. </template>
  100. <script>
  101. import TemplatePage from '@/components/template/template-page-1.vue'
  102. import { mapGetters } from 'vuex'
  103. import {
  104. getList,
  105. addDataList,
  106. getCodeApi,
  107. stopTaker,
  108. deleDataList,
  109. v2TakerRecordList,
  110. v2TakerRecordListExport
  111. } from '@/api/basic_data/taker'
  112. import { getDealerList } from '@/api/basic_data/dealer'
  113. import { downloadFiles } from '@/utils/util'
  114. import fileUpload from '@/components/Common/file-upload.vue'
  115. export default {
  116. components: {
  117. fileUpload,
  118. TemplatePage
  119. },
  120. computed: {
  121. ...mapGetters(['customerId', 'customerName']),
  122. exParams() {
  123. return {
  124. customerName: this.searchForm.customerName,
  125. takerName: this.searchForm.takerName,
  126. phoneKeyword: this.searchForm.phoneKeyword
  127. }
  128. }
  129. },
  130. data() {
  131. return {
  132. // 事件组合
  133. optionsEvensGroup: [
  134. [
  135. [
  136. {
  137. name: '新增',
  138. click: () => {
  139. this.addFn()
  140. },
  141. isRole: this.$checkBtnRole('add', this.$route.meta.roles)
  142. }
  143. ]
  144. ]
  145. ],
  146. // 表格属性
  147. tableAttributes: {
  148. // 启用勾选列
  149. selectColumn: false
  150. },
  151. // 表格事件
  152. tableEvents: {
  153. 'selection-change': this.selectionChange
  154. },
  155. recordSelected: [],
  156. baseURL: process.env.VUE_APP_BASE_API,
  157. isCollapse: true,
  158. fileList: [],
  159. listLoading: false, // 列表加载loading
  160. currentPage: 1, // 当前页码
  161. pageSize: 10, // 每页数量
  162. listTotal: 0, // 列表总数
  163. addForm: {
  164. customerName: '',
  165. takerName: '',
  166. identity: '',
  167. phone: '',
  168. sparePhone: '',
  169. expireTime: '',
  170. code: ''
  171. },
  172. show: true, //验证码
  173. count: '',
  174. timer: null,
  175. rules: {
  176. customerId: [{ required: false, message: '请选择经销商', trigger: 'blur' }],
  177. takerName: [{ required: true, message: '请输入提货人姓名', trigger: 'blur' }],
  178. phone: [
  179. {
  180. required: true,
  181. message: '请输入联系电话',
  182. trigger: 'blur'
  183. },
  184. {
  185. required: true,
  186. 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}$/,
  187. message: '联系电话格式不正确',
  188. trigger: 'blur'
  189. }
  190. ],
  191. sparePhone: [
  192. {
  193. required: false,
  194. 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}$/,
  195. message: '请输入备用电话',
  196. trigger: 'blur'
  197. }
  198. ],
  199. expireTime: [{ required: true, message: '有效期不能为空', trigger: 'blur' }]
  200. // code: [{ required: true, message: "验证码不能为空", trigger: "blur" }],
  201. },
  202. dialogForm: false,
  203. dataList: [],
  204. searchForm: {
  205. customerName: '',
  206. takerName: '',
  207. phoneKeyword: ''
  208. },
  209. dealerList: [],
  210. id: '', //重建之前的Id
  211. showOK: true
  212. }
  213. },
  214. created() {
  215. // this.getDataList()
  216. // await this.getDealerDataList({ pageNum: 1, pageSize: 10 });
  217. },
  218. methods: {
  219. // 列表请求函数
  220. getList: v2TakerRecordList,
  221. // 列表导出函数
  222. exportList: v2TakerRecordListExport,
  223. // 表格列解析渲染数据更改
  224. columnParsing(item, defaultData) {
  225. return defaultData
  226. },
  227. // 监听勾选变化
  228. selectionChange(data) {
  229. this.recordSelected = data
  230. },
  231. operation() {
  232. return (h, { row, index, column }) => {
  233. return (
  234. <div class="operation-btns">
  235. <el-button
  236. size="mini"
  237. type="text"
  238. onClick={async () => {
  239. this.seeFn(row)
  240. }}
  241. >
  242. 查看
  243. </el-button>
  244. {this.$checkBtnRole('del', this.$route.meta.roles) ? (
  245. <el-popconfirm
  246. onOnConfirm={async () => {
  247. this.deleFn(row.id)
  248. }}
  249. title="是否确定需要删除该项内容?"
  250. >
  251. <el-button slot="reference" size="mini" type="text">
  252. 删除
  253. </el-button>
  254. </el-popconfirm>
  255. ) : (
  256. ''
  257. )}
  258. {row.flag === 1 ? (
  259. <el-button
  260. size="mini"
  261. type="text"
  262. onClick={async () => {
  263. this.stopFn(row.id)
  264. }}
  265. >
  266. 停用
  267. </el-button>
  268. ) : (
  269. ''
  270. )}
  271. {row.flag === 2 ? (
  272. <el-button
  273. size="mini"
  274. type="text"
  275. onClick={async () => {
  276. this.rebuild(row)
  277. }}
  278. >
  279. 重建
  280. </el-button>
  281. ) : (
  282. ''
  283. )}
  284. </div>
  285. )
  286. }
  287. },
  288. //重建
  289. rebuild(data) {
  290. this.showOK = true
  291. this.id = data.id
  292. this.addForm = {
  293. customerName: data.customerName,
  294. takerName: data.takerName,
  295. identity: data.identity,
  296. phone: data.phone,
  297. sparePhone: data.sparePhone,
  298. expireTime: '',
  299. code: ''
  300. }
  301. this.fileList = []
  302. this.dialogForm = true
  303. },
  304. //删除
  305. async deleFn(ids) {
  306. await deleDataList({ ids })
  307. this.$message.success('删除成功')
  308. // this.getDataList()
  309. this.$refs.pageRef.refreshList()
  310. },
  311. //查看
  312. seeFn(data) {
  313. this.showOK = false
  314. this.addForm = data
  315. this.fileList = []
  316. this.dialogForm = true
  317. },
  318. //取消
  319. cancelFn() {
  320. if (this.addForm.id) {
  321. this.addForm = {
  322. takerName: '',
  323. identity: '',
  324. phone: '',
  325. sparePhone: '',
  326. expireTime: '',
  327. code: ''
  328. }
  329. } else {
  330. this.$refs.addForm.resetFields()
  331. }
  332. this.count = 0
  333. this.dialogForm = false
  334. },
  335. //上传
  336. handlefile(response, file, fileList) {
  337. console.log(response, file, fileList)
  338. },
  339. // //导出
  340. // exportFn() {
  341. // let screenData = {
  342. // customerName: this.searchForm.customerName,
  343. // takerName: this.searchForm.takerName,
  344. // };
  345. // downloadFiles("/taker-record/export", screenData);
  346. // },
  347. //停用提货人档案
  348. async stopFn(id) {
  349. await stopTaker({ id })
  350. this.$message.success('成功')
  351. // this.getDataList()
  352. this.$refs.pageRef.refreshList()
  353. },
  354. //获取验证码
  355. async getCodeFn() {
  356. const res = await getCodeApi({ mobile: this.addForm.phone })
  357. const TIME_COUNT = 60 //倒计时的初始值
  358. this.count = TIME_COUNT
  359. this.show = false
  360. this.timer = setInterval(() => {
  361. if (this.count > 0 && this.count <= TIME_COUNT) {
  362. this.count--
  363. } else {
  364. this.show = true
  365. clearInterval(this.timer)
  366. this.timer = null
  367. }
  368. }, 1000)
  369. },
  370. //获取经销商数据
  371. async getDealerDataList(data) {
  372. const res = await getDealerList(data)
  373. this.dealerList = res.data.records
  374. },
  375. //获取列表数据
  376. async getDataList() {
  377. let params = {
  378. customerName: this.searchForm.customerName,
  379. takerName: this.searchForm.takerName,
  380. phoneKeyword: this.searchForm.phoneKeyword,
  381. pageNum: this.currentPage,
  382. pageSize: this.pageSize
  383. }
  384. let res = await getList(params)
  385. this.dataList = res.data.records
  386. this.listTotal = res.data.total
  387. },
  388. //搜索功能
  389. async searchFn() {
  390. this.currentPage = 1
  391. await this.getDataList()
  392. },
  393. //重置
  394. clearFn() {
  395. this.$refs.searchForm.resetFields()
  396. },
  397. // 更改每页数量
  398. handleSizeChange(val) {
  399. this.pageSize = val
  400. this.currentPage = 1
  401. this.getDataList()
  402. },
  403. // 更改当前页
  404. handleCurrentChange(val) {
  405. this.currentPage = val
  406. this.getDataList()
  407. },
  408. //新增
  409. async addDataFn() {
  410. await this.$refs.addForm.validate()
  411. // const res = this.dealerList.filter(
  412. // (v) => v.id === this.addForm.customerId
  413. // )[0];
  414. // console.log(res);
  415. if (this.fileList.length == 1) {
  416. await addDataList({
  417. ...this.addForm,
  418. customerId: this.customerId,
  419. fileName: this.fileList[0].name,
  420. fileUrl: this.fileList[0].url
  421. })
  422. } else {
  423. await addDataList({
  424. ...this.addForm,
  425. customerId: this.customerId,
  426. fileName: '',
  427. fileUrl: ''
  428. })
  429. }
  430. if (this.id) {
  431. await deleDataList({ ids: this.id })
  432. }
  433. this.$message.success('新增成功')
  434. this.id = ''
  435. // this.addForm = {
  436. // customerId: "",
  437. // takerName: "",
  438. // identity: "",
  439. // phone: "",
  440. // sparePhone: "",
  441. // expireTime: "",
  442. // code: "",
  443. // };
  444. this.count = 0
  445. // this.getDataList()
  446. this.$refs.pageRef.refreshList()
  447. this.dialogForm = false
  448. },
  449. addFn() {
  450. this.addForm = {
  451. customerName: this.customerName,
  452. takerName: '',
  453. identity: '',
  454. phone: '',
  455. sparePhone: '',
  456. expireTime: '',
  457. code: ''
  458. }
  459. this.fileList = []
  460. this.showOK = true
  461. this.dialogForm = true
  462. }
  463. }
  464. }
  465. </script>
  466. <style lang="scss" scoped>
  467. ::v-deep .el-date-editor {
  468. width: 100%;
  469. }
  470. ::v-deep .el-select {
  471. width: 100%;
  472. }
  473. ::v-deep .el-col-9 .el-button {
  474. padding: 5px;
  475. margin: 6px;
  476. }
  477. ::v-deep .el-dialog__header {
  478. background-color: #dddddd;
  479. }
  480. .base {
  481. padding: 20px 20px 0;
  482. }
  483. .table {
  484. margin-top: 12px;
  485. }
  486. .right {
  487. float: right;
  488. }
  489. </style>