TabelTransfer.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. <template>
  2. <div>
  3. <slot name="header">
  4. <el-row class="radio">
  5. <el-radio-group v-model="region">
  6. <el-radio label="">全部经销商</el-radio>
  7. <!-- <el-radio label="1">地区</el-radio>-->
  8. <!-- <el-radio label="2">指定</el-radio>-->
  9. </el-radio-group>
  10. <el-upload
  11. class="import-btn"
  12. :action="baseURL + 'student/import'"
  13. :http-request="handleImport"
  14. :file-list="importFileList"
  15. :show-file-list="false"
  16. >
  17. <el-button
  18. type="primary"
  19. size="small"
  20. >导入经销商</el-button>
  21. </el-upload>
  22. <el-button
  23. type="primary"
  24. size="small"
  25. @click="hanleDownloadFiles"
  26. >下载模板</el-button>
  27. </el-row>
  28. <el-row type="flex">
  29. <el-col>
  30. <el-input
  31. v-model="keyword"
  32. placeholder="查找经销商"
  33. size="small"
  34. />
  35. </el-col>
  36. <el-col style="margin-left: 10px"><el-button size="small" @click="getList">确定</el-button></el-col>
  37. </el-row>
  38. </slot>
  39. <el-row :gutter="20">
  40. <el-col :span="10" :offset="0">
  41. <h5>未选经销商</h5>
  42. <el-divider
  43. direction="horizontal"
  44. content-position="left"
  45. />
  46. <el-table
  47. ref="multipleTable"
  48. :data="dataL"
  49. element-loading-text="Loading"
  50. border
  51. height="480px"
  52. fit
  53. highlight-current-row
  54. @select-all="handleSelectionAllChange"
  55. @selection-change="handleSelectionChange"
  56. >
  57. <el-table-column
  58. type="selection"
  59. width="55"
  60. :selectable="selectable"
  61. align="center"
  62. />
  63. <!-- <el-table-column-->
  64. <!-- prop="number"-->
  65. <!-- label="经销商编码"-->
  66. <!-- align="center"-->
  67. <!-- />-->
  68. <el-table-column
  69. prop="name"
  70. label="经销商名称"
  71. align="center"
  72. />
  73. </el-table>
  74. <!-- 分页 -->
  75. <div style="margin: 20px 0">
  76. <el-pagination
  77. :current-page="currentPages"
  78. :page-sizes="[10, 20, 30, 50]"
  79. :page-size="10"
  80. layout="total, sizes, prev, pager, next, jumper"
  81. :total="clistTotal"
  82. @size-change="handleSizeChanges"
  83. @current-change="handleCurrentChanges"
  84. />
  85. </div>
  86. </el-col>
  87. <el-col :span="4" class="middle_box" :offset="0">
  88. <el-col>
  89. <el-button
  90. size="small"
  91. :disabled="type == 2"
  92. @click="handleAllAdd"
  93. >全部添加</el-button></el-col>
  94. <el-col>
  95. <el-button
  96. size="small"
  97. :disabled="type == 2"
  98. @click="handleAdd"
  99. >增加</el-button></el-col>
  100. <el-col>
  101. <el-button
  102. size="small"
  103. :disabled="type == 1"
  104. @click="handleDelete"
  105. >删除</el-button></el-col>
  106. <el-col>
  107. <el-button
  108. size="small"
  109. :disabled="type == 1"
  110. @click="handleAllDelete"
  111. >全部删除</el-button></el-col>
  112. </el-col>
  113. <el-col :span="10" :offset="0">
  114. <h5>已选经销商</h5>
  115. <el-divider
  116. direction="horizontal"
  117. content-position="left"
  118. />
  119. <el-table
  120. v-loading="listLoading"
  121. :data="custoList"
  122. element-loading-text="Loading"
  123. border
  124. height="480px"
  125. fit
  126. highlight-current-row
  127. stripe
  128. @select-all="handleSelectionAllChange2"
  129. @selection-change="handleSelectionChange2"
  130. >
  131. <el-table-column type="selection" width="55" align="center" />
  132. <!-- <el-table-column-->
  133. <!-- prop="customerNumber"-->
  134. <!-- label="经销商编码"-->
  135. <!-- align="center"-->
  136. <!-- />-->
  137. <el-table-column
  138. prop="customerName"
  139. label="经销商名称"
  140. align="center"
  141. />
  142. </el-table>
  143. </el-col>
  144. </el-row>
  145. <slot name="footer">
  146. <el-row style="margin:20px 0 0 0;">
  147. <el-button
  148. type="primary"
  149. size="small"
  150. @click="handleSave"
  151. > {{ comCode?'保存':'提交审核' }} </el-button>
  152. <el-button type="primary" size="small" @click="handleReset">重置</el-button>
  153. </el-row>
  154. </slot>
  155. </div>
  156. </template>
  157. <script>
  158. import { deleteCondition, deleteMaterialPolicy, getConditionList, getCrList, getCustomerList } from '@/api/policy_list'
  159. import { downloadFiles, handleImport } from '@/utils/util'
  160. import EditCondition from './EditCondition'
  161. import ImageUpload from '@/components/Common/image-upload.vue'
  162. import Minxin from '@/mixin'
  163. export default {
  164. name: 'Examine',
  165. components: {
  166. EditCondition,
  167. ImageUpload
  168. },
  169. mixins: [Minxin],
  170. // eslint-disable-next-line vue/require-prop-types
  171. props: ['code'],
  172. data() {
  173. return {
  174. keyword: '',
  175. region: '',
  176. baseURL: '',
  177. dcurrentPage: 1,
  178. dpageSize: 10,
  179. dlistTotal: 0,
  180. currentPages: 1, // 当前页码
  181. pageSizes: 10, // 每页数量
  182. input: '',
  183. remark: '',
  184. fileList: [],
  185. listLoading: false,
  186. imageUrl: '',
  187. dataList: [],
  188. examineStatus: 'OK',
  189. options: {},
  190. value: '',
  191. detail: {},
  192. srcList: [],
  193. screenForm: {
  194. code: '',
  195. createBy: '',
  196. endCreateTime: '',
  197. endTime1: '',
  198. endTime2: '',
  199. examineBy: '',
  200. remark: '',
  201. startCreateTime: '',
  202. startTime1: '',
  203. startTime2: '',
  204. status: '',
  205. title: '',
  206. type: ''
  207. },
  208. conditionList: [],
  209. custoList: [],
  210. isEdit: 1,
  211. cid: '',
  212. cpolicyId: '',
  213. dataL: [],
  214. clistTotal: 0,
  215. clistTotals: 0,
  216. type: 1,
  217. importFileList: [],
  218. leftData: [],
  219. rightData: [],
  220. typeOptions: [
  221. {
  222. value: 'PROVISION',
  223. label: '配提'
  224. },
  225. {
  226. value: 'LIMIT',
  227. label: '限量'
  228. }
  229. ],
  230. comCode: ''
  231. }
  232. },
  233. created() {
  234. this.comCode = this.code
  235. if (this.comCode) {
  236. this.getCond()
  237. }
  238. },
  239. updated() {
  240. this.comCode = this.code
  241. console.log(this.code, 'kkkkk')
  242. },
  243. methods: {
  244. getList() {
  245. this.getCrList()
  246. },
  247. getCrList() {
  248. const customerParams = {
  249. pageNum: this.currentPages,
  250. pageSize: this.pageSizes,
  251. keyword: this.keyword,
  252. region: ''
  253. }
  254. // 获取经销商列表
  255. getCrList(customerParams).then((res) => {
  256. this.dataL = res.data.records
  257. for (let j = 0; j < this.custoList.length; j++) {
  258. for (let i = 0; i < res.data.records.length; i++) {
  259. if (res.data.records[i].id === this.custoList[j].customerId) {
  260. res.data.records[i].disabled = true
  261. }
  262. }
  263. }
  264. for (let k = 0; k < this.dataL.length; k++) {
  265. (this.dataL[k].customerId = this.dataL[k].id),
  266. (this.dataL[k].customerName = this.dataL[k].name),
  267. (this.dataL[k].customerNumber = this.dataL[k].number)
  268. }
  269. this.clistTotal = res.data.total
  270. })
  271. },
  272. // 更改每页数量
  273. handleSizeChanges(val) {
  274. this.pageSizes = val
  275. this.currentPages = 1
  276. this.getCrList()
  277. },
  278. // 更改当前页
  279. handleCurrentChanges(val) {
  280. this.currentPages = val
  281. this.getCrList()
  282. },
  283. // 去掉相同数据
  284. resArr(arr1, arr2) {
  285. return arr1.filter((v) => arr2.every((val) => val.id !== v.id))
  286. },
  287. // 导入经销商模板
  288. async handleImport(param) {
  289. this.importLoading = true
  290. const file = param.file
  291. const formData = new FormData()
  292. formData.append('file', file)
  293. // formData.append('policyId', this.searchForm.code)
  294. // formData.append("mainId", this.searchForm.mainId);
  295. const result = await handleImport('/policy/importCustomer', formData)
  296. console.log(result)
  297. this.importLoading = false
  298. this.importFileList = []
  299. if (result.code === 200) {
  300. await this.$alert(result.message, '导入成功', {
  301. confirmButtonText: '确定'
  302. })
  303. for (let i = 0; i < result.data.length; i++) {
  304. result.data[i].customerNumber = result.data[i].number
  305. result.data[i].customerName = result.data[i].name
  306. }
  307. if (this.custoList.length) {
  308. this.custoList = [...this.custoList, ...this.resArr(this.custoList, result.data)]
  309. } else {
  310. this.custoList = result.data
  311. }
  312. } else {
  313. await this.$alert(result.message, '导入失败', {
  314. confirmButtonText: '确定'
  315. })
  316. }
  317. },
  318. // 下载经销商模板
  319. hanleDownloadFiles() {
  320. downloadFiles('/policy/downloadCustomer')
  321. },
  322. getCommonApi(row) {
  323. (this.isEdit = 2), (this.cid = row.id), (this.cpolicyId = row.policyId)
  324. console.log(
  325. this.cpolicyId,
  326. this.comCode,
  327. this.cpolicyId == this.comCode
  328. )
  329. },
  330. getCond() {
  331. console.log(this.code, 'hhjkhkj', this.comCode, '999999')
  332. this.listLoading = true
  333. const custoParams = {
  334. pageNum: this.currentPages,
  335. pageSize: this.pageSizes,
  336. policyId: this.comCode || this.code
  337. }
  338. getCustomerList(custoParams).then((res) => {
  339. this.custoList = res.data.records
  340. console.log(this.custoList, '已选的')
  341. this.clistTotals = res.data.total
  342. this.listLoading = false
  343. // this.getCrList()
  344. })
  345. },
  346. handleCondition(id, index) {
  347. deleteCondition({ id }).then((res) => {
  348. this.getConditionList()
  349. this.$successMsg('删除成功')
  350. })
  351. },
  352. getConditionList() {
  353. const condParams = {
  354. policyId: this.comCode
  355. }
  356. getConditionList(condParams).then((res) => {
  357. this.conditionList = res.data
  358. })
  359. },
  360. // 删除
  361. hanleDelete(id) {
  362. const params = { policyMaterialId: id }
  363. deleteMaterialPolicy(params).then((res) => {
  364. this.$successMsg('删除成功')
  365. })
  366. },
  367. /**
  368. * 根据条件禁用行复选框
  369. * 函数返回值为false则禁用选择(反之亦然)
  370. * @param {Object} row - 行数据
  371. * @param {String} index - 索引值
  372. * @return Boolean
  373. */
  374. selectable: function(row, index) {
  375. // row.disabled == undefined 才能被选中
  376. if (row.disabled == undefined || row.disabled == false) {
  377. return true
  378. } else {
  379. return false
  380. }
  381. // 函数必须有返回值且是布尔值
  382. // 页面刷新后该函数会执行 N 次进行判断(N 为表格行数)
  383. // 如果没有返回值则默认返回false(全部无法选中)
  384. },
  385. handleSelectionAllChange(e) {
  386. this.leftData = e
  387. this.type = 1
  388. },
  389. handleSelectionChange(e) {
  390. this.leftData = e
  391. this.type = 1
  392. },
  393. handleSelectionAllChange2(e) {
  394. this.rightData = e
  395. this.type = 2
  396. },
  397. handleSelectionChange2(e) {
  398. this.rightData = e
  399. this.type = 2
  400. },
  401. handleLeft(e) {
  402. this.type = 1
  403. },
  404. handleRight(e) {
  405. this.type = 2
  406. },
  407. handleAllAdd() {
  408. if (this.type == 1 && this.leftData.length) {
  409. for (let i = 0; i < this.dataL.length; i++) {
  410. for (let j = 0; j < this.leftData.length; j++) {
  411. if (this.dataL[i].id == this.leftData[j].id) {
  412. this.dataL[i].disabled = true
  413. }
  414. }
  415. }
  416. this.custoList = [...this.custoList, ...this.leftData]
  417. this.$refs.multipleTable.clearSelection()
  418. } else {
  419. this.$errorMsg('请选择要添加的经销商')
  420. }
  421. },
  422. handleAllDelete() {
  423. if (this.type === 2 && this.rightData.length) {
  424. for (let i = 0; i < this.dataL.length; i++) {
  425. for (let j = 0; j < this.rightData.length; j++) {
  426. if (this.dataL[i].id === this.rightData[j].customerId) {
  427. this.$set(this.dataL[i], 'disabled', false)
  428. // this.dataL[i].disabled = false
  429. }
  430. }
  431. }
  432. const arr = this.resArr(this.custoList, this.rightData)
  433. this.custoList = arr
  434. } else {
  435. this.$errorMsg('请选择要删除的经销商')
  436. }
  437. },
  438. handleAdd() {
  439. if (this.type === 1 && this.leftData.length) {
  440. for (let i = 0; i < this.dataL.length; i++) {
  441. for (let j = 0; j < this.leftData.length; j++) {
  442. if (this.dataL[i].id === this.leftData[j].id) {
  443. this.dataL[i].disabled = true
  444. }
  445. }
  446. }
  447. this.custoList = [...this.custoList, ...this.leftData]
  448. this.leftData = []
  449. this.$refs.multipleTable.clearSelection()
  450. } else {
  451. this.$errorMsg('请选择要添加的经销商')
  452. }
  453. },
  454. handleDelete() {
  455. if (this.type === 2 && this.rightData.length) {
  456. for (let i = 0; i < this.dataL.length; i++) {
  457. for (let j = 0; j < this.rightData.length; j++) {
  458. if (this.dataL[i].id === this.rightData[j].customerId) {
  459. this.$set(this.dataL[i], 'disabled', false)
  460. // this.dataL[i].disabled = false
  461. }
  462. }
  463. }
  464. const arr = this.resArr(this.custoList, this.rightData)
  465. this.custoList = arr
  466. } else {
  467. this.$errorMsg('请选择要删除的经销商')
  468. }
  469. },
  470. // 提交数据
  471. async handleSave() {
  472. this.$emit('handlEditPolicy', this.custoList)
  473. },
  474. handleReset() {
  475. this.dataR = this.rightData = []
  476. this.keyword = ''
  477. this.$emit('handleReset')
  478. }
  479. }
  480. }
  481. </script>
  482. <style lang="scss" scoped>
  483. .radio{
  484. display: flex;
  485. align-items: center;
  486. margin: 0 0 20px 0;
  487. }
  488. .import-btn{
  489. margin:0 10px;
  490. }
  491. .el-col {
  492. //overflow: hidden;
  493. }
  494. .value{
  495. ::v-deep .el-input__prefix{
  496. display: none;
  497. }
  498. }
  499. .descriptions {
  500. // border: #EBEEF5;
  501. border: 1px solid #ebeef5;
  502. border-bottom: none;
  503. .el-row {
  504. height: 40px;
  505. line-height: 40px;
  506. }
  507. .el-col:nth-child(odd) {
  508. background-color: #ebeef5;
  509. }
  510. .el-col {
  511. padding: 0 15px;
  512. height: 100%;
  513. border-bottom: 1px solid #ebeef5;
  514. }
  515. }
  516. .el-divider--horizontal {
  517. margin: 20px 0;
  518. }
  519. .col {
  520. height: 100px;
  521. }
  522. .import-btn {
  523. margin-right: 10px;
  524. display: inline-block;
  525. }
  526. ::v-deep .el-input__icon .el-icon-time{
  527. display: none;
  528. }
  529. .middle_box {
  530. margin-top: 80px;
  531. text-align: center;
  532. height: 430px;
  533. display: flex;
  534. flex-direction: column;
  535. align-content: center;
  536. justify-content: space-between;
  537. align-items: center;
  538. }
  539. .img-box {
  540. height: 150px;
  541. display: flex;
  542. align-items: center;
  543. }
  544. </style>