<template>
|
<div class="app-container">
|
<!--工具栏-->
|
<div class="head-container">
|
<div v-if="crud.props.searchToggle">
|
<!-- 搜索 -->
|
<el-input v-model="query.businessPlace" clearable placeholder="营业地" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
|
<el-input v-model="query.businessContent" clearable placeholder="营业内容" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
|
<el-select v-model="query.businessStatus" filterable clearable placeholder="营业状态" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery">
|
<el-option
|
v-for="item in dict[businessStatus]"
|
:key="item.id"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
<rrOperation :crud="crud" />
|
</div>
|
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
|
<crudOperation :permission="permission" />
|
<!--表单组件-->
|
<el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="600px">
|
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
|
<el-form-item label="营业地" prop="businessPlace">
|
<el-input v-model="form.businessPlace" style="width: 470px;" />
|
</el-form-item>
|
<el-form-item label="营业内容" prop="businessContent">
|
<el-input v-model="form.businessContent" :rows="3" type="textarea" style="width: 470px;" />
|
</el-form-item>
|
<el-form-item label="营业状态" prop="businessStatus">
|
<el-select v-model="form.businessStatus" filterable placeholder="请选择" style="width: 470px;">
|
<el-option
|
v-for="item in dict[businessStatus]"
|
:key="item.id"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-button size="mini" type="primary" icon="el-icon-plus" style="position: relative; left: 464px;" @click="personnelAdd()" />
|
<el-table ref="table" :data="form.businessPlanPersonnelDtoList" size="small" style="width: 100%;">
|
<el-table-column :show-overflow-tooltip="true" prop="userNickName" label="所属用户" />
|
<el-table-column :show-overflow-tooltip="true" prop="businessPlanStartDate" label="营业计划开始日期">
|
<template slot-scope="scope">
|
{{ crud.toDate(scope.row.businessPlanStartDate) }}
|
</template>
|
</el-table-column>
|
<el-table-column :show-overflow-tooltip="true" prop="businessPlanEndDate" label="营业计划结束日期">
|
<template slot-scope="scope">
|
{{ crud.toDate(scope.row.businessPlanEndDate) }}
|
</template>
|
</el-table-column>
|
<el-table-column label="操作" width="150px" align="center">
|
<template slot-scope="scope">
|
<el-button size="mini" type="primary" icon="el-icon-edit" @click="personnelEdit(scope.row)" />
|
<el-button size="mini" type="danger" icon="el-icon-delete" @click="personnelDelete(scope.row)" />
|
</template>
|
</el-table-column>
|
</el-table>
|
<el-form-item label="备注" style="margin-top: 20px;">
|
<el-input v-model="form.remarks" :rows="3" type="textarea" style="width: 470px;" />
|
</el-form-item>
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<el-button type="text" @click="crud.cancelCU">取消</el-button>
|
<el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
|
</div>
|
</el-dialog>
|
<!--表格渲染-->
|
<el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
|
<el-table-column type="selection" width="55" />
|
<el-table-column type="expand">
|
<template slot-scope="props">
|
<el-table :data="props.row.businessPlanPersonnelDtoList" style="margin: 10px 20px 10px 105px; width: calc(100% - 20px - 105px);">
|
<el-table-column :show-overflow-tooltip="true" prop="userNickName" label="所属用户" />
|
<el-table-column :show-overflow-tooltip="true" prop="businessPlanStartDate" label="营业计划开始日期">
|
<template slot-scope="scope">
|
{{ crud.toDate(scope.row.businessPlanStartDate) }}
|
</template>
|
</el-table-column>
|
<el-table-column :show-overflow-tooltip="true" prop="businessPlanEndDate" label="营业计划结束日期">
|
<template slot-scope="scope">
|
{{ crud.toDate(scope.row.businessPlanEndDate) }}
|
</template>
|
</el-table-column>
|
<el-table-column :show-overflow-tooltip="true" prop="remarks" label="备注" />
|
</el-table>
|
</template>
|
</el-table-column>
|
<el-table-column :show-overflow-tooltip="true" prop="businessPlace" label="营业地" />
|
<el-table-column :show-overflow-tooltip="true" prop="businessContent" label="营业内容" />
|
<el-table-column :show-overflow-tooltip="true" prop="businessStatus" label="营业状态">
|
<template slot-scope="scope">
|
<el-tag>{{ dict.label[businessStatus][scope.row.businessStatus] }}</el-tag>
|
</template>
|
</el-table-column>
|
<el-table-column :show-overflow-tooltip="true" prop="remarks" label="备注" />
|
<el-table-column :show-overflow-tooltip="true" prop="createTime" label="创建时间" />
|
<el-table-column v-if="checkPer(['admin','businessPlan:edit','businessPlan:del'])" label="操作" width="150px" align="center">
|
<template slot-scope="scope">
|
<udOperation
|
:data="scope.row"
|
:permission="permission"
|
/>
|
</template>
|
</el-table-column>
|
</el-table>
|
<!--分页组件-->
|
<pagination />
|
<!--表单组件-->
|
<el-dialog :close-on-click-modal="false" :before-close="personnelCancel" :visible.sync="personnelStatus" :title="personnelTitle" width="600px">
|
<el-form ref="personnelForm" :model="personnelForm" :rules="personnelRules" size="small" label-width="140px">
|
<el-form-item label="所属用户" prop="userId">
|
<el-select v-model="personnelForm.userId" placeholder="请选择" filterable clearable style="width: 410px;" @change="personnelFormUserIdChange">
|
<el-option
|
v-for="item in userList"
|
:key="item.id"
|
:label="item.nickName"
|
:value="item.id"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="营业计划开始日期" prop="businessPlanStartDate">
|
<el-date-picker v-model="personnelForm.businessPlanStartDate" type="date" style="width: 410px;" />
|
</el-form-item>
|
<el-form-item label="营业计划结束日期" prop="businessPlanEndDate">
|
<el-date-picker v-model="personnelForm.businessPlanEndDate" type="date" style="width: 410px;" />
|
</el-form-item>
|
<el-form-item label="备注">
|
<el-input v-model="personnelForm.remarks" :rows="3" type="textarea" style="width: 410px;" />
|
</el-form-item>
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<el-button type="text" @click="personnelCancel">取消</el-button>
|
<el-button :loading="personnelLoading" type="primary" @click="personnelSubmit('personnelForm')">确认</el-button>
|
</div>
|
</el-dialog>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
import crudBusinessPlan from '@/api/business/plan'
|
import CRUD, { presenter, header, form, crud } from '@crud/crud'
|
import rrOperation from '@crud/RR.operation'
|
import crudOperation from '@crud/CRUD.operation'
|
import udOperation from '@crud/UD.operation'
|
import pagination from '@crud/Pagination'
|
import constant from '../../../utils/constant'
|
import crudUser from '@/api/system/user'
|
|
const defaultForm = { id: null, businessPlace: null, businessContent: null, businessStatus: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null, businessPlanPersonnelDtoList: [] }
|
export default {
|
name: 'BusinessPlan',
|
components: { pagination, crudOperation, rrOperation, udOperation },
|
mixins: [presenter(), header(), form(defaultForm), crud()],
|
dicts: [constant.BUSINESS_STATUS],
|
cruds() {
|
return CRUD({ title: '营业计划', url: 'api/businessPlan', idField: 'id', sort: 'id,desc', crudMethod: { ...crudBusinessPlan }})
|
},
|
data() {
|
return {
|
permission: {
|
add: ['admin', 'businessPlan:add'],
|
edit: ['admin', 'businessPlan:edit'],
|
del: ['admin', 'businessPlan:del'],
|
download: ['admin', 'businessPlan:download']
|
},
|
rules: {
|
businessPlace: [
|
{ required: true, message: '营业地不能为空', trigger: 'blur' },
|
{ min: 2, max: 100, message: '长度在 2 到 100 个字符', trigger: 'blur' }
|
],
|
businessContent: [
|
{ required: true, message: '营业内容不能为空', trigger: 'blur' }
|
],
|
businessStatus: [
|
{ required: true, message: '营业状态不能为空', trigger: 'change' }
|
]
|
},
|
queryTypeOptions: [
|
{ key: 'businessPlace', display_name: '营业地' },
|
{ key: 'businessContent', display_name: '营业内容' },
|
{ key: 'businessStatus', display_name: '营业状态' }
|
],
|
// 字典:营业状态
|
businessStatus: constant.BUSINESS_STATUS,
|
// 营业计划人员弹窗状态
|
personnelStatus: false,
|
// 营业计划人员弹窗标题
|
personnelTitle: '营业计划人员',
|
// 营业计划人员弹窗表单
|
personnelForm: {},
|
// 营业计划人员弹窗验证
|
personnelRules: {
|
businessPlanId: [
|
{ required: true, message: '所属营业计划不能为空', trigger: 'change' }
|
],
|
userId: [
|
{ required: true, message: '所属用户不能为空', trigger: 'change' }
|
],
|
businessPlanStartDate: [
|
{ required: true, message: '营业计划开始日期不能为空', trigger: 'change' }
|
],
|
businessPlanEndDate: [
|
{ required: true, message: '营业计划结束日期不能为空', trigger: 'change' }
|
]
|
},
|
// 营业计划人员弹窗操作
|
personnelExecute: {},
|
// 营业计划人员弹窗加载
|
personnelLoading: false,
|
// 用户列表
|
userList: []
|
}
|
},
|
methods: {
|
// 钩子:在获取表格数据之前执行,false 则代表不获取数据
|
[CRUD.HOOK.beforeRefresh]() {
|
// 获取用户
|
this.getUser()
|
return true
|
},
|
// 获取用户
|
getUser() {
|
// 获取用户
|
crudUser.getAll().then(res => {
|
// 用户列表
|
this.userList = res
|
})
|
},
|
// 营业计划人员弹窗用户ID变更
|
personnelFormUserIdChange() {
|
// 指针重定义
|
const _this = this
|
// 筛选用户列表
|
const personnelInfo = this.userList.filter(function(item) {
|
return item.id === _this.personnelForm.userId
|
})
|
// 营业计划人员弹窗表单
|
this.personnelForm.userNickName = personnelInfo[0].nickName
|
},
|
// 营业计划人员弹窗新增
|
personnelAdd() {
|
// 指针重定义
|
const _this = this
|
// 营业计划人员弹窗表单
|
this.personnelForm = {}
|
// 营业计划人员弹窗状态
|
this.personnelStatus = true
|
// 营业计划人员弹窗操作
|
this.personnelExecute = {}
|
// 表单清空
|
setTimeout(function() {
|
_this.$refs['personnelForm'].clearValidate()
|
}, 3)
|
},
|
// 营业计划人员弹窗修改
|
personnelEdit(data) {
|
// 营业计划人员弹窗表单
|
this.personnelForm = JSON.parse(JSON.stringify(data))
|
// 营业计划人员弹窗状态
|
this.personnelStatus = true
|
// 营业计划人员弹窗操作
|
this.personnelExecute = JSON.parse(JSON.stringify(data))
|
},
|
// 营业计划人员弹窗删除
|
personnelDelete(data) {
|
// 指针重定义
|
const _this = this
|
// 筛选营业计划人员
|
const personnelInfo = this.crud.form.businessPlanPersonnelDtoList.filter(function(item) {
|
return item.userId === data.userId && _this.crud.toDate(item.businessPlanStartDate) === _this.crud.toDate(data.businessPlanStartDate) && _this.crud.toDate(item.businessPlanEndDate) === _this.crud.toDate(data.businessPlanEndDate)
|
})
|
// 获取下标
|
const subscript = this.crud.form.businessPlanPersonnelDtoList.indexOf(personnelInfo[0])
|
// 营业计划人员移除元素
|
this.crud.form.businessPlanPersonnelDtoList.splice(subscript, 1)
|
},
|
// 营业计划人员弹窗关闭
|
personnelCancel() {
|
// 营业计划人员弹窗状态
|
this.personnelStatus = false
|
},
|
// 营业计划人员弹窗提交
|
personnelSubmit(formName) {
|
this.$refs[formName].validate((valid) => {
|
if (valid) {
|
// 判断营业计划人员弹窗操作
|
if (this.personnelExecute.userId !== undefined) {
|
// 营业计划人员弹编辑
|
// 指针重定义
|
const _this = this
|
// 筛选营业计划人员弹
|
const personnelInfo = this.crud.form.businessPlanPersonnelDtoList.filter(function(item) {
|
return item.userId === _this.personnelExecute.userId && _this.crud.toDate(item.businessPlanStartDate) === _this.crud.toDate(_this.personnelExecute.businessPlanStartDate) && _this.crud.toDate(item.businessPlanEndDate) === _this.crud.toDate(_this.personnelExecute.businessPlanEndDate)
|
})
|
// 营业计划人员弹更新
|
personnelInfo[0].userId = this.personnelForm.userId
|
personnelInfo[0].userNickName = this.personnelForm.userNickName
|
personnelInfo[0].businessPlanStartDate = this.personnelForm.businessPlanStartDate
|
personnelInfo[0].businessPlanEndDate = this.personnelForm.businessPlanEndDate
|
personnelInfo[0].remarks = this.personnelForm.remarks
|
} else {
|
// 营业计划人员新增
|
this.crud.form.businessPlanPersonnelDtoList.push(this.personnelForm)
|
}
|
// 营业计划人员弹窗关闭
|
this.personnelCancel()
|
} else {
|
return false
|
}
|
})
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
|
</style>
|