yzxy-mobile/pages/distribute/index.vue

356 lines
9.4 KiB
Vue
Raw Permalink Normal View History

2024-08-26 17:24:26 +08:00
<template>
<div v-if="istrue" class="distribute plr30">
<div class="flex_start flex_items mt40">
<div @click="chosewho('1')" :class="['f-center', 'f26',curindex==1?'chosethis':'nochose']"
style="width:50%;height: 76rpx;line-height: 76rpx;border-radius: 8rpx 0rpx 0 8rpx;">
内容分发
</div>
<div @click="chosewho('0')" :class="['f-center', 'f26',curindex==0?'chosethis':'nochose']"
style="width:50%;height: 76rpx;line-height: 76rpx;border-radius: 0 8rpx 8rpx 0;">
预算划拨</div>
</div>
<!-- t2 -->
<div v-if="curindex==0" class="mt40 bgwhite pt20 pb40 pr20"
style="box-shadow: 0rpx 10rpx 16rpx 0rpx rgba(220,224,236,0.28);border-radius: 16rpx;">
<view class="flex_between flex_items">
<view class="flex_start flex_items">
<view
style="width: 12rpx;height: 51rpx;background: #100072;border-radius: 12rpx 40rpx 40rpx 12rpx;">
</view>
<text class="f28 bold ml30" style="color: #000;">操作人</text>
</view>
<text class="f24 mr20" style="color: #1F1057;">{{name}}</text>
</view>
<view class="flex_between flex_items">
<text class="f26 ml15 bold" style="color: #333333;">额度</text>
<van-field :disabled="isdis" class="mr20" input-align="right" style="width: 200rpx;padding-right: 0;"
v-model="form.integral" label="" placeholder="额度" />
</view>
<view class="flex_between flex_items">
<text class="f26 ml15 bold" style="color: #333333;">分发缘由</text>
<van-field :disabled="isdis" class="mr20" input-align="right" style="width: 200rpx;padding-right: 0"
v-model="form.subject" label="" placeholder="分发缘由" />
</view>
<view class="flex_between flex_items">
<text class="f26 ml15 bold" style="color: #333333;">分发对象</text>
<view v-if="isdis" style="height: 88rpx;"></view>
<view v-else>
<SelectCheckBox kind="duo" @confirm="confirm" types="user" label="" placeholder="请选择"
requireMessage="请选择" :columns="users" :selectValue="form.userIds" label-width="100"
:option="{ label: 'name', value: 'id' }" />
</view>
</view>
<view class="mt60 flex_items flex_center">
<view @click="godis('duo')" class="flex_items flex_center"
style="width: 654rpx;height: 86rpx;background:linear-gradient(90deg, #A21E2E 0%, #190F58 100%);box-shadow: 0rpx 8rpx 14rpx 0rpx rgba(83,139,135,0.2);border-radius: 12rpx;">
<text class="f28" style="color: #fff;">确认分发</text>
</view>
</view>
</div>
<div v-else class="mt40 bgwhite pt20 pb40 pr20"
style="box-shadow: 0rpx 10rpx 16rpx 0rpx rgba(220,224,236,0.28);border-radius: 16rpx;">
<view class="flex_between flex_items">
<view class="flex_start flex_items">
<view
style="width: 12rpx;height: 51rpx;background: #100072;border-radius: 12rpx 40rpx 40rpx 12rpx;">
</view>
<text class="f28 bold ml30" style="color: #000;">操作人</text>
</view>
<text class="f24 mr20" style="color: #1F1057;">{{name}}</text>
</view>
<view class="flex_between flex_items">
<text class="f26 ml15 bold" style="color: #333333;">姓名</text>
<van-field class="mr20" input-align="right" style="width: 200rpx;padding-right: 0;"
v-model="form2.username" label="" placeholder="姓名" />
</view>
<view class="flex_between flex_items">
<text class="f26 ml15 bold" style="color: #333333;">手机号码</text>
<van-field class="mr20" input-align="right" style="width: 200rpx;padding-right: 0;"
v-model="form2.mobile" label="" placeholder="手机号码" />
</view>
<view class="flex_between flex_items">
<text class="f26 ml15 bold" style="color: #333333;">分发项目</text>
<view>
<SelectCheckBox kind="dan" @confirm2="confirm2" types="user" label="" placeholder="请选择"
requireMessage="请选择" :columns="items" :selectradio="form2.import_id" label-width="100"
:option="{ label: 'name', value: 'id' }" />
</view>
</view>
<view class="mt60 flex_items flex_center">
<view @click="godis('dan')" class="flex_items flex_center"
style="width: 654rpx;height: 86rpx;background:linear-gradient(90deg, #A21E2E 0%, #190F58 100%);box-shadow: 0rpx 8rpx 14rpx 0rpx rgba(83,139,135,0.2);border-radius: 12rpx;">
<text class="f28" style="color: #fff;">确认分发</text>
</view>
</view>
</div>
</div>
</div>
</template>
<script>
import SelectCheckBox from "./chosemore"
import {
Picker
} from 'vant'
export default {
data() {
return {
curindex: 1,
istrue: false,
form: {
integral: "",
subject: "",
type: 2,
userIds: [],
productType: "integral",
},
customerBusinessAll: [],
users: [],
showPicker: false,
typename: "积分",
form2: {
mobile: "",
import_id: ""
},
list: [],
name: uni.getStorageSync('adminname'),
items: [],
nickname: uni.getStorageSync('nickname'),
isdis: false
}
},
components: {
SelectCheckBox
},
onLoad(options) {
console.log(this.nickname)
if (this.nickname != "超级管理员") {
this.isdis = true
}
this.getprople()
},
methods: {
chosewho(val) {
this.curindex = val
if (val == 1) {
this.getprople()
} else {
this.getuser()
}
},
getuser() {
uni.showLoading({
title: "加载中..."
})
this.api.getusers(this.form2).then((res) => {
console.log(res)
if (res.data.code == 200) {
this.users = res.data.data
this.istrue = true
} else {
this.istrue = true
uni.hideLoading()
uni.showToast({
title: res.data.message,
icon: 'none'
})
}
})
},
getprople() {
uni.showLoading({
title: "加载中..."
})
this.items = []
this.api.getitems(this.form2).then((res) => {
console.log(res)
if (res.data.code == 200) {
res.data.data.forEach((item, index) => {
item.id = item.id + ''
this.items.push(item)
})
this.istrue = true
} else {
this.istrue = true
uni.hideLoading()
uni.showToast({
title: res.data.message,
icon: 'none'
})
}
})
},
getrecored() {
uni.showLoading({
title: "加载中..."
})
this.api.getrecord(this.form2).then((res) => {
console.log(res)
if (res.data.code == 200) {
uni.stopPullDownRefresh();
if (res.data.data.data.length != 0) {
res.data.data.data.forEach((item, index) => {
this.list.push(item)
})
this.istrue = true
} else {
this.istrue = true
uni.showToast({
title: '暂无数据',
icon: 'none'
})
return false
}
} else {
this.istrue = true
uni.hideLoading()
uni.showToast({
title: res.data.message,
icon: 'none'
})
}
})
},
// onConfirm(val) {
// this.form.productType = val.value
// this.typename = val.text
// this.showPicker = false
// },
confirm(val) {
if (val.types == 'product') {
this.form.productIds = val.arr
} else {
this.form.userIds = val.arr
}
},
confirm2(val) {
this.form2.import_id = val
},
godis(item, types) {
uni.showLoading({
title: "分发中..."
})
if (item == 'duo') {
this.goduo()
} else {
this.godan()
}
},
goduo() {
let that = this
that.api.godistribute(that.form).then((res) => {
console.log(res)
if (res.data.code == 200) {
uni.hideLoading()
uni.showToast({
title: "划拨成功",
icon: "success",
duration: 1200
})
setTimeout(function() {
uni.navigateTo({
url: "/pages/directory/index"
})
}, 1200);
} else {
that.istrue = true
uni.hideLoading()
uni.showToast({
title: res.data.message,
icon: 'none'
})
}
// if (that.form.productType == 'integral') {
// that.form.productType = 0
// } else {
// that.form.productType = 1
// }
})
},
godan() {
let that = this
that.api.fenout(that.form2).then((res) => {
console.log(res)
if (res.data.code == 200) {
uni.hideLoading()
uni.showToast({
title: "分发成功",
icon: "success",
duration: 1200
})
setTimeout(function() {
uni.switchTab({
url: "/pages/index/index"
})
}, 1200);
} else {
that.istrue = true
uni.hideLoading()
uni.showToast({
title: res.data.message,
icon: 'none'
})
}
if (that.form.productType == 'integral') {
that.form.productType = 0
} else {
that.form.productType = 1
}
})
},
},
onReachBottom() {
uni.showLoading({
title: "加载中..."
})
setTimeout(() => {
this.form2.page += 1
this.getrecored()
}, 1000)
},
onPullDownRefresh() {
this.form2.page = 1
this.list = []
this.form2.name = ""
this.getrecored()
}
}
</script>
<style scoped>
page {
background: #FAFBFD !important;
}
.chosethis {
background: #1F1057;
color: #fff;
border: 2rpx solid #1F1057;
}
.nochose {
border: 2rpx solid #1F1057;
color: #1F1057;
}
.xia .van-dropdown-menu__item {
box-shadow: none !important;
}
.distribute .van-dropdown-menu__bar {
box-shadow: none !important;
}
.distribute .van-field__control {
text-align: right !important;
}
.one {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 1;
line-clamp: 1;
-webkit-box-orient: vertical;
}
</style>