123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552 |
- <template>
- <div>
- <slot name="header">
- <el-row class="radio">
- <el-radio-group v-model="region">
- <el-radio label="">全部经销商</el-radio>
- <!-- <el-radio label="1">地区</el-radio>-->
- <!-- <el-radio label="2">指定</el-radio>-->
- </el-radio-group>
- <el-upload
- class="import-btn"
- :action="baseURL + 'student/import'"
- :http-request="handleImport"
- :file-list="importFileList"
- :show-file-list="false"
- >
- <el-button
- type="primary"
- size="small"
- >导入经销商</el-button>
- </el-upload>
- <el-button
- type="primary"
- size="small"
- @click="hanleDownloadFiles"
- >下载模板</el-button>
- </el-row>
- <el-row type="flex">
- <el-col>
- <el-input
- v-model="keyword"
- placeholder="查找经销商"
- size="small"
- />
- </el-col>
- <el-col style="margin-left: 10px"><el-button size="small" @click="getList">确定</el-button></el-col>
- </el-row>
- </slot>
- <el-row :gutter="20">
- <el-col :span="10" :offset="0">
- <h5>未选经销商</h5>
- <el-divider
- direction="horizontal"
- content-position="left"
- />
- <el-table
- ref="multipleTable"
- :data="dataL"
- element-loading-text="Loading"
- border
- height="480px"
- fit
- highlight-current-row
- @select-all="handleSelectionAllChange"
- @selection-change="handleSelectionChange"
- >
- <el-table-column
- type="selection"
- width="55"
- :selectable="selectable"
- align="center"
- />
- <!-- <el-table-column-->
- <!-- prop="number"-->
- <!-- label="经销商编码"-->
- <!-- align="center"-->
- <!-- />-->
- <el-table-column
- prop="name"
- label="经销商名称"
- align="center"
- />
- </el-table>
- <!-- 分页 -->
- <div style="margin: 20px 0">
- <el-pagination
- :current-page="currentPages"
- :page-sizes="[10, 20, 30, 50]"
- :page-size="10"
- layout="total, sizes, prev, pager, next, jumper"
- :total="clistTotal"
- @size-change="handleSizeChanges"
- @current-change="handleCurrentChanges"
- />
- </div>
- </el-col>
- <el-col :span="4" class="middle_box" :offset="0">
- <el-col>
- <el-button
- size="small"
- :disabled="type == 2"
- @click="handleAllAdd"
- >全部添加</el-button></el-col>
- <el-col>
- <el-button
- size="small"
- :disabled="type == 2"
- @click="handleAdd"
- >增加</el-button></el-col>
- <el-col>
- <el-button
- size="small"
- :disabled="type == 1"
- @click="handleDelete"
- >删除</el-button></el-col>
- <el-col>
- <el-button
- size="small"
- :disabled="type == 1"
- @click="handleAllDelete"
- >全部删除</el-button></el-col>
- </el-col>
- <el-col :span="10" :offset="0">
- <h5>已选经销商</h5>
- <el-divider
- direction="horizontal"
- content-position="left"
- />
- <el-table
- v-loading="listLoading"
- :data="custoList"
- element-loading-text="Loading"
- border
- height="480px"
- fit
- highlight-current-row
- stripe
- @select-all="handleSelectionAllChange2"
- @selection-change="handleSelectionChange2"
- >
- <el-table-column type="selection" width="55" align="center" />
- <!-- <el-table-column-->
- <!-- prop="customerNumber"-->
- <!-- label="经销商编码"-->
- <!-- align="center"-->
- <!-- />-->
- <el-table-column
- prop="customerName"
- label="经销商名称"
- align="center"
- />
- </el-table>
- </el-col>
- </el-row>
- <slot name="footer">
- <el-row style="margin:20px 0 0 0;">
- <el-button
- type="primary"
- size="small"
- @click="handleSave"
- > {{ comCode?'保存':'提交审核' }} </el-button>
- <el-button type="primary" size="small" @click="handleReset">重置</el-button>
- </el-row>
- </slot>
- </div>
- </template>
- <script>
- import { deleteCondition, deleteMaterialPolicy, getConditionList, getCrList, getCustomerList } from '@/api/policy_list'
- import { downloadFiles, handleImport } from '@/utils/util'
- import EditCondition from './EditCondition'
- import ImageUpload from '@/components/Common/image-upload.vue'
- import Minxin from '@/mixin'
- export default {
- name: 'Examine',
- components: {
- EditCondition,
- ImageUpload
- },
- mixins: [Minxin],
- // eslint-disable-next-line vue/require-prop-types
- props: ['code'],
- data() {
- return {
- keyword: '',
- region: '',
- baseURL: '',
- dcurrentPage: 1,
- dpageSize: 10,
- dlistTotal: 0,
- currentPages: 1, // 当前页码
- pageSizes: 10, // 每页数量
- input: '',
- remark: '',
- fileList: [],
- listLoading: false,
- imageUrl: '',
- dataList: [],
- examineStatus: 'OK',
- options: {},
- value: '',
- detail: {},
- srcList: [],
- screenForm: {
- code: '',
- createBy: '',
- endCreateTime: '',
- endTime1: '',
- endTime2: '',
- examineBy: '',
- remark: '',
- startCreateTime: '',
- startTime1: '',
- startTime2: '',
- status: '',
- title: '',
- type: ''
- },
- conditionList: [],
- custoList: [],
- isEdit: 1,
- cid: '',
- cpolicyId: '',
- dataL: [],
- clistTotal: 0,
- clistTotals: 0,
- type: 1,
- importFileList: [],
- leftData: [],
- rightData: [],
- typeOptions: [
- {
- value: 'PROVISION',
- label: '配提'
- },
- {
- value: 'LIMIT',
- label: '限量'
- }
- ],
- comCode: ''
- }
- },
- created() {
- this.comCode = this.code
- if (this.comCode) {
- this.getCond()
- }
- },
- updated() {
- this.comCode = this.code
- console.log(this.code, 'kkkkk')
- },
- methods: {
- getList() {
- this.getCrList()
- },
- getCrList() {
- const customerParams = {
- pageNum: this.currentPages,
- pageSize: this.pageSizes,
- keyword: this.keyword,
- region: ''
- }
- // 获取经销商列表
- getCrList(customerParams).then((res) => {
- this.dataL = res.data.records
- for (let j = 0; j < this.custoList.length; j++) {
- for (let i = 0; i < res.data.records.length; i++) {
- if (res.data.records[i].id === this.custoList[j].customerId) {
- res.data.records[i].disabled = true
- }
- }
- }
- for (let k = 0; k < this.dataL.length; k++) {
- (this.dataL[k].customerId = this.dataL[k].id),
- (this.dataL[k].customerName = this.dataL[k].name),
- (this.dataL[k].customerNumber = this.dataL[k].number)
- }
- this.clistTotal = res.data.total
- })
- },
- // 更改每页数量
- handleSizeChanges(val) {
- this.pageSizes = val
- this.currentPages = 1
- this.getCrList()
- },
- // 更改当前页
- handleCurrentChanges(val) {
- this.currentPages = val
- this.getCrList()
- },
- // 去掉相同数据
- resArr(arr1, arr2) {
- return arr1.filter((v) => arr2.every((val) => val.id !== v.id))
- },
- // 导入经销商模板
- async handleImport(param) {
- this.importLoading = true
- const file = param.file
- const formData = new FormData()
- formData.append('file', file)
- // formData.append('policyId', this.searchForm.code)
- // formData.append("mainId", this.searchForm.mainId);
- const result = await handleImport('/policy/importCustomer', formData)
- console.log(result)
- this.importLoading = false
- this.importFileList = []
- if (result.code === 200) {
- await this.$alert(result.message, '导入成功', {
- confirmButtonText: '确定'
- })
- for (let i = 0; i < result.data.length; i++) {
- result.data[i].customerNumber = result.data[i].number
- result.data[i].customerName = result.data[i].name
- }
- if (this.custoList.length) {
- this.custoList = [...this.custoList, ...this.resArr(this.custoList, result.data)]
- } else {
- this.custoList = result.data
- }
- } else {
- await this.$alert(result.message, '导入失败', {
- confirmButtonText: '确定'
- })
- }
- },
- // 下载经销商模板
- hanleDownloadFiles() {
- downloadFiles('/policy/downloadCustomer')
- },
- getCommonApi(row) {
- (this.isEdit = 2), (this.cid = row.id), (this.cpolicyId = row.policyId)
- console.log(
- this.cpolicyId,
- this.comCode,
- this.cpolicyId == this.comCode
- )
- },
- getCond() {
- console.log(this.code, 'hhjkhkj', this.comCode, '999999')
- this.listLoading = true
- const custoParams = {
- pageNum: this.currentPages,
- pageSize: this.pageSizes,
- policyId: this.comCode || this.code
- }
- getCustomerList(custoParams).then((res) => {
- this.custoList = res.data.records
- console.log(this.custoList, '已选的')
- this.clistTotals = res.data.total
- this.listLoading = false
- // this.getCrList()
- })
- },
- handleCondition(id, index) {
- deleteCondition({ id }).then((res) => {
- this.getConditionList()
- this.$successMsg('删除成功')
- })
- },
- getConditionList() {
- const condParams = {
- policyId: this.comCode
- }
- getConditionList(condParams).then((res) => {
- this.conditionList = res.data
- })
- },
- // 删除
- hanleDelete(id) {
- const params = { policyMaterialId: id }
- deleteMaterialPolicy(params).then((res) => {
- this.$successMsg('删除成功')
- })
- },
- /**
- * 根据条件禁用行复选框
- * 函数返回值为false则禁用选择(反之亦然)
- * @param {Object} row - 行数据
- * @param {String} index - 索引值
- * @return Boolean
- */
- selectable: function(row, index) {
- // row.disabled == undefined 才能被选中
- if (row.disabled == undefined || row.disabled == false) {
- return true
- } else {
- return false
- }
- // 函数必须有返回值且是布尔值
- // 页面刷新后该函数会执行 N 次进行判断(N 为表格行数)
- // 如果没有返回值则默认返回false(全部无法选中)
- },
- handleSelectionAllChange(e) {
- this.leftData = e
- this.type = 1
- },
- handleSelectionChange(e) {
- this.leftData = e
- this.type = 1
- },
- handleSelectionAllChange2(e) {
- this.rightData = e
- this.type = 2
- },
- handleSelectionChange2(e) {
- this.rightData = e
- this.type = 2
- },
- handleLeft(e) {
- this.type = 1
- },
- handleRight(e) {
- this.type = 2
- },
- handleAllAdd() {
- if (this.type == 1 && this.leftData.length) {
- for (let i = 0; i < this.dataL.length; i++) {
- for (let j = 0; j < this.leftData.length; j++) {
- if (this.dataL[i].id == this.leftData[j].id) {
- this.dataL[i].disabled = true
- }
- }
- }
- this.custoList = [...this.custoList, ...this.leftData]
- this.$refs.multipleTable.clearSelection()
- } else {
- this.$errorMsg('请选择要添加的经销商')
- }
- },
- handleAllDelete() {
- if (this.type === 2 && this.rightData.length) {
- for (let i = 0; i < this.dataL.length; i++) {
- for (let j = 0; j < this.rightData.length; j++) {
- if (this.dataL[i].id === this.rightData[j].customerId) {
- this.$set(this.dataL[i], 'disabled', false)
- // this.dataL[i].disabled = false
- }
- }
- }
- const arr = this.resArr(this.custoList, this.rightData)
- this.custoList = arr
- } else {
- this.$errorMsg('请选择要删除的经销商')
- }
- },
- handleAdd() {
- if (this.type === 1 && this.leftData.length) {
- for (let i = 0; i < this.dataL.length; i++) {
- for (let j = 0; j < this.leftData.length; j++) {
- if (this.dataL[i].id === this.leftData[j].id) {
- this.dataL[i].disabled = true
- }
- }
- }
- this.custoList = [...this.custoList, ...this.leftData]
- this.leftData = []
- this.$refs.multipleTable.clearSelection()
- } else {
- this.$errorMsg('请选择要添加的经销商')
- }
- },
- handleDelete() {
- if (this.type === 2 && this.rightData.length) {
- for (let i = 0; i < this.dataL.length; i++) {
- for (let j = 0; j < this.rightData.length; j++) {
- if (this.dataL[i].id === this.rightData[j].customerId) {
- this.$set(this.dataL[i], 'disabled', false)
- // this.dataL[i].disabled = false
- }
- }
- }
- const arr = this.resArr(this.custoList, this.rightData)
- this.custoList = arr
- } else {
- this.$errorMsg('请选择要删除的经销商')
- }
- },
- // 提交数据
- async handleSave() {
- this.$emit('handlEditPolicy', this.custoList)
- },
- handleReset() {
- this.dataR = this.rightData = []
- this.keyword = ''
- this.$emit('handleReset')
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .radio{
- display: flex;
- align-items: center;
- margin: 0 0 20px 0;
- }
- .import-btn{
- margin:0 10px;
- }
- .el-col {
- //overflow: hidden;
- }
- .value{
- ::v-deep .el-input__prefix{
- display: none;
- }
- }
- .descriptions {
- // border: #EBEEF5;
- border: 1px solid #ebeef5;
- border-bottom: none;
- .el-row {
- height: 40px;
- line-height: 40px;
- }
- .el-col:nth-child(odd) {
- background-color: #ebeef5;
- }
- .el-col {
- padding: 0 15px;
- height: 100%;
- border-bottom: 1px solid #ebeef5;
- }
- }
- .el-divider--horizontal {
- margin: 20px 0;
- }
- .col {
- height: 100px;
- }
- .import-btn {
- margin-right: 10px;
- display: inline-block;
- }
- ::v-deep .el-input__icon .el-icon-time{
- display: none;
- }
- .middle_box {
- margin-top: 80px;
- text-align: center;
- height: 430px;
- display: flex;
- flex-direction: column;
- align-content: center;
- justify-content: space-between;
- align-items: center;
- }
- .img-box {
- height: 150px;
- display: flex;
- align-items: center;
- }
- </style>
|