You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

276 lines
6.6 KiB

2 years ago
<template>
<view class="content">
2 years ago
<view class="content_item_box">
<view class="content_item">
<view class="">
<text style="color: red;">*</text>任务名称
</view>
<view class="">
2 years ago
<radio-group v-if="!isSupervisor" class="radio-group" name="" @change="task($event)">
2 years ago
<label class="radio" style="margin-right: 20rpx" v-for="(item,key) in data1" :key="item.name">
<radio color="#317AFF" :value="item.name" />
<text>{{item.name}}</text>
</label>
</radio-group>
2 years ago
<radio-group v-else class="radio-group" name="" @change="task($event)">
<label class="radio" style="margin-right: 20rpx" v-for="(item,key) in data2" :key="item.name">
<radio color="#317AFF" :value="item.name" />
<text>{{item.name}}</text>
</label>
</radio-group>
2 years ago
</view>
2 years ago
</view>
2 years ago
<view class="content_item">
<view class="">
<text style="color: red;">*</text>单位名称
</view>
<superwei-combox :isJSON="true" :candidates="companies" keyName="companyName" placeholder="请选择或输入"
v-model="companyName" @select="bbb($event)" @input="getCompanies($event)"></superwei-combox>
2 years ago
</view>
2 years ago
<view class="content_item">
<view class="">
<text style="color: red;">*</text>协助机构
</view>
2 years ago
<checkbox-group v-if="!isSupervisor" class="checkbox-group" @change="aaa($event)">
2 years ago
<label v-for="(item,key) in supervisorList " :key="key" class="checkbox">
<checkbox color="#317AFF" style="transform: scale(0.7);" :value="item.id" />
<text>{{item.name}}</text>
</label>
</checkbox-group>
<checkbox-group v-else class="checkbox-group" @change="aaa($event)">
<label v-for="(item,key) in og " :key="key" class="checkbox">
<checkbox color="#317AFF" style="transform: scale(0.7);" :value="item.id" />
<text>{{item.name}}</text>
</label>
</checkbox-group>
2 years ago
</view>
</view>
2 years ago
<view class="button">
<button @tap="apply()">确定</button>
<!-- <button type="default">取消</button> -->
2 years ago
</view>
</view>
</template>
<script>
export default {
2 years ago
props: {
rightAction: {
type: Function,
default () {
return () => {}
}
},
},
2 years ago
data() {
return {
2 years ago
dataSource: [{
label: '选项1',
id: '1'
},
{
label: '选项2',
id: '2'
},
],
data1: [{
name: "熟悉演练",
value: 1
}],
data2: [{
name: "双随机",
value: 1,
}, {
name: "联络指导",
value: 0
}],
users: [],
supervisorList: [],
og: [],
companies: [],
curry: 0,
prams: {
task: "",
company: "",
supervisor: []
},
companyName: "",
selectedYear: 2022,
selectedMonth: 0,
OrganizationId: "",
isSupervisor: false
}
},
created() {
let roles = uni.getStorageSync("user").roles
console.log(uni.getStorageSync("user"));
let isSupervisor = roles.find(item => {
return item.name.indexOf('检查') != -1
})
isSupervisor ? this.isSupervisor = true : this.isSupervisor = false
this.OrganizationId = uni.getStorageSync("user").organizationId
this.getSupervisor()
this.getOg()
this.getUsers()
// this.getCompanies()
this.selectedMonth = new Date().getMonth() + 1
this.selectedYear = new Date().getFullYear()
},
methods: {
getSupervisor() {
this.$request.get('/api/Users/Inspectors', {}, (data, res) => {
this.supervisorList = res
console.log(this.supervisorList);
})
},
getOg() {
let p = {
PageNumber: 1,
PageSize: 9999
}
this.$request.get('/api/Organizations', p, (data, res) => {
2 years ago
this.og=[]
for(let i=0;i<res.items.length;i++){
if(res.items[i].level=="squadron"){
this.og.push(res.items[i])
}
}
// this.og = res.items
2 years ago
})
},
aaa(e) {
console.log(e);
this.prams.supervisor = e.detail.value
},
task(e) {
console.log(e);
this.prams.task = e.detail.value
},
getCompanies(e) {
let params = {
companyName: e,
OrganizationId: this.OrganizationId,
PageNumber: 1,
PageSize: 50
}
this.$request.get('/api/Companies', params, (data, res) => {
console.log(res);
this.companies = res.items
})
},
getUsers() {
let p = {
OrganizationId: this.OrganizationId,
OrganizationLevel: 'squadron',
ContainsChildren: true,
PageNumber: 1,
PageSize: 9999
}
this.$request.get('/api/Users', p, (data, res) => {
console.log(res);
this.users = res.items
})
},
companyname(e) {
console.log(e);
this.companyName = this.companies[e.detail.value].companyName
},
bbb(e) {
2 years ago
console.log(e,7800);
this.prams.company=e.id
2 years ago
},
apply() {
if (!this.prams.task || !this.prams.company || !this.prams.supervisor.length) {
return this.$alert.showError("请填写完整")
}
let selectedMonth = this.selectedMonth < 10 ? "0" + this.selectedMonth : this.selectedMonth;
let selectedTime = this.selectedYear + '-' + selectedMonth + '-' + '01'
2 years ago
console.log(this.prams,444);
2 years ago
let body = {
month: selectedTime,
taskName: this.prams.task,
taskType: this.prams.task,
companyId: this.prams.company,
organizationId: this.OrganizationId,
2 years ago
supervisorIds: this.isSupervisor ? [] : this.prams.supervisor,
assitantOrganizationIds: this.isSupervisor ? this.prams.supervisor : [],
2 years ago
creationType: '申领任务',
approvalStatus: '待处理'
}
2 years ago
// return
2 years ago
this.$request.post('/api/PlanTasks', body, (data, res) => {
console.log(res);
if (res.status == 500) {
this.$alert.showError("该单位已创建任务")
} else {
this.$alert.showError("创建成功")
}
this.$parent.apply();
})
2 years ago
}
}
}
</script>
<style lang="scss">
.content {
2 years ago
height: 100%;
display: flex;
flex-direction: column;
padding: 0 20rpx;
.content_item_box {
flex: 1;
overflow: auto;
}
2 years ago
.content_item {
display: flex;
2 years ago
align-items: center;
padding: 20rpx 0;
view {
margin: 0 20rpx;
}
.input {
flex: 1;
height: 60rpx;
border: 2rpx solid #E4E7EC;
}
}
.button {
display: flex;
height: 150rpx;
}
.checkbox-group,
.radio-group {
flex: 1;
overflow: auto;
.checkbox,
.radio {
margin-bottom: 10rpx;
margin-right: 10rpx;
radio {
transform: scale(0.7);
}
}
2 years ago
}
}
</style>