TabelTransfer.vue 15 KB

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