|
@@ -0,0 +1,208 @@
|
|
|
+<style lang="scss" scoped>
|
|
|
+.child-plan{
|
|
|
+
|
|
|
+}
|
|
|
+.dialog-style{
|
|
|
+ div{
|
|
|
+ text-align: center;
|
|
|
+ margin: 5px;
|
|
|
+ label{
|
|
|
+ display: inline-block;
|
|
|
+ width: 100px;
|
|
|
+ text-align: right;
|
|
|
+ }
|
|
|
+ .el-textarea,.el-input{
|
|
|
+ display: inline-block;
|
|
|
+ width: 300px;
|
|
|
+ }
|
|
|
+ .text-label{
|
|
|
+ vertical-align: top;
|
|
|
+ margin-top: 10px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+.add-bt{
|
|
|
+ padding: 15px;
|
|
|
+ text-align: right;
|
|
|
+}
|
|
|
+.el-icon-edit{
|
|
|
+ font-size: 20px;
|
|
|
+ cursor: pointer;
|
|
|
+}
|
|
|
+</style>
|
|
|
+<template>
|
|
|
+<div class="child-plan">
|
|
|
+ <el-table :data="childPlan">
|
|
|
+ <el-table-column property="name" label="计划"></el-table-column>
|
|
|
+ <el-table-column property="content" label="简要说明"></el-table-column>
|
|
|
+ <el-table-column property="departmentName" label="部门"></el-table-column>
|
|
|
+ <el-table-column fixed="right" label="操作" width="120">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-button @click="changeData(scope.row, true)" type="text" size="small">详情</el-button>
|
|
|
+ <el-button @click="changeData(scope.row, false)" type="text" size="small">修改</el-button>
|
|
|
+ <el-button @click="visibleDelete = true;plan.id = scope.row.id" type="text" size="small">删除</el-button>
|
|
|
+ </template></el-table-column>
|
|
|
+ </el-table>
|
|
|
+ <div class="add-bt">
|
|
|
+ <el-button type="primary" @click="addPlan">新增</el-button>
|
|
|
+ </div>
|
|
|
+ <el-dialog
|
|
|
+ class="dialog-style"
|
|
|
+ :title="noEdit?'详情':'编辑'"
|
|
|
+ :visible.sync="visibleChange"
|
|
|
+ :modal="false"
|
|
|
+ width="500px">
|
|
|
+ <div>
|
|
|
+ <label>名称:</label>
|
|
|
+ <el-input name="name" v-model="plan.name" placeholder="请输入名称" required="required" :disabled="noEdit"></el-input>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <label class="text-label">内容:</label>
|
|
|
+ <el-input v-model="plan.content" placeholder="请输入内容" required="required" :disabled="noEdit" type="textarea" :autosize="{ minRows: 5}"></el-input>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <label>部门:</label>
|
|
|
+ <el-input v-model="currentDepart.name" required="required" disabled style="width:280px"></el-input>
|
|
|
+ <i class="el-icon-edit" @click="departChange = true"></i>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <label class="text-label">备注:</label>
|
|
|
+ <el-input v-model="plan.remark" placeholder="请输入内容" :disabled="noEdit" type="textarea" :autosize="{ minRows: 2}"></el-input>
|
|
|
+ </div>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button type="primary" @click="visibleChange = false;plan={}" v-if="!noEdit">取消</el-button>
|
|
|
+ <el-button type="primary" @click="saveChildPlan" v-if="!noEdit">确 定</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+ <el-dialog
|
|
|
+ title="提示"
|
|
|
+ :visible.sync="visibleDelete"
|
|
|
+ :modal="false"
|
|
|
+ width="200px">
|
|
|
+ <p class="center-text">确认删除?</p>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="visibleDelete = false;plan={}">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="deletePlan">确 定</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+ <el-dialog
|
|
|
+ class="dialog-style"
|
|
|
+ title="切换部门"
|
|
|
+ :modal="false"
|
|
|
+ :visible.sync="departChange"
|
|
|
+ width="500px">
|
|
|
+ <p>选择:{{currentDepart.name}}</p>
|
|
|
+ <UserTree :showUser="false" @chooseUser="chooseDepart"></UserTree>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="departChange = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="changeCheckDepart">确 定</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+</div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { getPlanList,addPlan,updatePlan,deletePlan } from '@/api/childPlan';
|
|
|
+import UserTree from "@/components/MainPage/Department/UserTree";
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'ChildPlan',
|
|
|
+ props:{
|
|
|
+ parentPlan: {},
|
|
|
+ showTable: {
|
|
|
+ type: Boolean,default: false,
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ childPlan: [],
|
|
|
+ params:{
|
|
|
+ planningId: this.parentPlan.id,
|
|
|
+ type: 1
|
|
|
+ },
|
|
|
+ plan:{},
|
|
|
+ visibleChange: false,
|
|
|
+ visibleDelete: false,
|
|
|
+ noEdit: false,
|
|
|
+ departChange: false,
|
|
|
+ currentDepart: {
|
|
|
+ name:''
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ components:{
|
|
|
+ UserTree
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.getPlanList();
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ showTable(val) {
|
|
|
+ if(val){
|
|
|
+ this.params.planningId = this.parentPlan.id;
|
|
|
+ this.getPlanList();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ getPlanList(){
|
|
|
+ getPlanList(this.params).then((data) => {
|
|
|
+ this.childPlan = data.data;
|
|
|
+ })
|
|
|
+ },
|
|
|
+ addPlan(){
|
|
|
+ this.visibleChange = true;
|
|
|
+ this.noEdit = false;
|
|
|
+ this.plan = {
|
|
|
+ content: '',
|
|
|
+ departmentId: '',
|
|
|
+ name: '',
|
|
|
+ planningId: this.parentPlan.id,
|
|
|
+ remark: '',
|
|
|
+ type: 1,
|
|
|
+ };
|
|
|
+ this.currentDepart.name = '';
|
|
|
+ },
|
|
|
+ deletePlan(){
|
|
|
+ deletePlan(this.plan).then((result) => {
|
|
|
+ alert(result?'删除成功':'删除失败');
|
|
|
+ this.visibleDelete = false;
|
|
|
+ this.plan = {};
|
|
|
+ this.getPlanList();
|
|
|
+ })
|
|
|
+ },
|
|
|
+ changeData(item,flag){
|
|
|
+ this.visibleChange = true;
|
|
|
+ this.noEdit = flag;
|
|
|
+ this.plan = JSON.parse(JSON.stringify( item ));
|
|
|
+ },
|
|
|
+ saveChildPlan(){
|
|
|
+ if(this.plan.id){
|
|
|
+ updatePlan(this.plan).then((result) => {
|
|
|
+ alert(result.result?'更新成功':'更新失败');
|
|
|
+ this.visibleChange = false;
|
|
|
+ this.plan = {};
|
|
|
+ this.getPlanList();
|
|
|
+ })
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ addPlan(this.plan).then((result) => {
|
|
|
+ alert(result.result?'添加成功':'添加失败');
|
|
|
+ this.visibleChange = false;
|
|
|
+ this.plan = {};
|
|
|
+ this.getPlanList();
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ chooseDepart(val){
|
|
|
+ this.currentDepart = val;
|
|
|
+ },
|
|
|
+ changeCheckDepart(){
|
|
|
+ this.plan.departmentId = this.currentDepart.id;
|
|
|
+ this.departChange = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|