123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370 |
- <template>
- <section>
- <!--工具条-->
- <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
- <el-form :inline="true" :model="filters">
- <el-form-item>
- <el-input v-model="filters.keyName" placeholder="请输入项目名称"></el-input>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" v-on:click="getProject">查询</el-button>
- </el-form-item>
- <el-form-item style="float:right;" v-if="user.parentId == 1">
- <el-button type="primary" @click="handleAdd">新增</el-button>
- </el-form-item>
- </el-form>
- </el-col>
- <!--列表-->
- <el-table :data="list" highlight-current-row v-loading="listLoading" :height="tableHeight" style="width: 100%;">
- <el-table-column type="index" width="60">
- </el-table-column>
- <el-table-column prop="projectName" label="项目名称" width="200" sortable>
- </el-table-column>
- <el-table-column prop="ownerCompanyName" label="生产方" min-width="200" sortable>
- </el-table-column>
- <el-table-column prop="charger" label="生产方负责人" min-width="150" sortable>
- </el-table-column>
- <el-table-column prop="creator" label="项目创建人" width="150" sortable>
- </el-table-column>
- <el-table-column prop="indate" label="创建时间" width="180" sortable>
- </el-table-column>
- <!-- <el-table-column label="操作" width="150">
- <template slot-scope="scope">
- <el-button size="small" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
- <el-button type="danger" size="small" @click="handleDel(scope.$index, scope.row)">删除</el-button>
- </template>
- </el-table-column> -->
- </el-table>
- <!--工具条-->
- <el-col :span="24" class="toolbar">
- <el-pagination
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- :page-sizes="[20 , 50 , 80 , 100]"
- :page-size="20"
- layout="total, sizes, prev, pager, next"
- :total="total"
- style="float:right;">
- </el-pagination>
- </el-col>
- <!--新增界面-->
- <el-dialog title="新增项目" v-if="addFormVisible" :visible.sync="addFormVisible" :close-on-click-modal="false" customClass='customWidth'>
- <el-form :model="addForm" label-width="120px" :rules="formRules" ref="addForm">
- <el-col :span="24">
- <el-form-item label="项目名称" prop="projectName">
- <el-input v-model="addForm.projectName" autocomplete="off" placeholder="请输入项目名称" style="width:510px"></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="24">
- <el-form-item label="生产方公司" prop="customerCompany">
- <el-select v-model="addForm.customerCompany" clearable filterable multiple placeholder="请选择生产方公司" @change="companyChange" value-key='id' style="width:510px">
- <!-- @change="companyChange(0)" -->
- <el-option v-for="item in company" :key="item.id" :label="item.companyName" :value="item">
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="24">
- <el-form-item label="项目经理" prop="managerId">
- <el-select v-model="addForm.managerId" clearable filterable placeholder="请选择项目经理" value-key='id' style="width:510px">
- <el-option v-for="item in charger" :key="item.id" :label="item.username" :value="item">
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <!-- <el-col :span="24">
- <el-form-item label="本方参与人">
- <el-select v-model="addForm.userA" clearable filterable multiple placeholder="请选择本方参与人" style="width:510px">
- <el-option v-for="item in userA" :key="item.id" :label="item.username" :value="item.id">
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="24">
- <el-form-item label="生产方参与人">
- <el-select v-model="addForm.userB" clearable filterable multiple placeholder="请选择生产方参与人" style="width:510px">
- <el-option v-for="item in userB" :key="item.id" :label="item.username" :value="item.id">
- </el-option>
- </el-select>
- </el-form-item>
- </el-col> -->
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button @click.native="addFormVisible = false">取消</el-button>
- <el-button type="primary" @click.native="addSubmit" :loading="addLoading">提交</el-button>
- </div>
- </el-dialog>
- </section>
- </template>
- <script>
- import util from '../../common/js/util'
- export default {
- data() {
- return {
- filters: {
- keyName: ''
- },
- user: JSON.parse(sessionStorage.getItem('user')),
- company:[],
- charger: [],
- // userA: [],
- // userB: [],
- list: [],
- total: 0,
- page: 1,
- size: 20,
- listLoading: false,
- tableHeight: 0,
- formRules: {
- projectName: [
- { required: true, message: '请输入项目名称', trigger: 'blur' }
- ],
- customerCompany: [
- { required: true, message: '请选择客户公司', trigger: 'blur' }
- ],
- managerId: [
- { required: true, message: '请选择项目经理', trigger: ['blur','change'] }
- ]
- },
-
- addFormVisible: false,//新增界面是否显示
- addLoading: false,
- //新增界面数据
- addForm: {
- projectName: '',
- customerCompany: [],
- managerId: '',
- // userA: [],
- // userB: []
- }
- }
- },
- methods: {
- // 获取基础数据
- getMsg(){
- this.http.post(this.port.project.getUserById, {
- companyIds: this.user.companyId
- } , res => {
- if (res.code == "ok") {
- this.charger = res.data;
- } else {
- this.$message({
- message: res.msg,
- type: 'error'
- });
- }
- }, error => {
- this.$message({
- message: error,
- type: 'error'
- });
- })
- this.http.post(this.port.base.companys, {
- parentId: this.user.parentId,
- id: this.user.id
- }, res => {
- if (res.code == "ok") {
- var list = res.data , array = [];
- for(var i in list){
- if(list[i].id != this.user.companyId){
- array.push(list[i])
- }
- }
- this.company = array;
- } else {
- this.$message({
- message: res.msg,
- type: 'error'
- });
- }
- }, error => {
- this.$message({
- message: error,
- type: 'error'
- });
- })
- },
- //分页
- handleCurrentChange(val) {
- this.page = val;
- this.getProject();
- },
- handleSizeChange(val) {
- this.size = val;
- this.getProject();
- },
-
- //获取项目列表
- getProject() {
- this.listLoading = true;
- this.http.post(this.port.project.projectList, {
- keyName: this.filters.keyName,
- currentPage: this.page,
- pageSize: this.size,
- }, res => {
- this.listLoading = false;
- if (res.code == "ok") {
- this.list = res.data.list;
- this.total = res.data.total;
- } else {
- this.$message({
- message: res.msg,
- type: 'error'
- });
- }
- }, error => {
- this.listLoading = false;
- this.$message({
- message: error,
- type: 'error'
- });
- })
- },
- //选择公司切换人员
- companyChange: function(){
- var param = {} ,
- str = this.user.companyId;
- for(var i in this.addForm.customerCompany){
- str += "," + this.addForm.customerCompany[i].id;
- }
- param.companyIds = str;
- this.http.post(this.port.project.getUserById, param , res => {
- if (res.code == "ok") {
- this.charger = res.data;
- } else {
- this.$message({
- message: res.msg,
- type: 'error'
- });
- }
- }, error => {
- this.$message({
- message: error,
- type: 'error'
- });
- })
- },
- //显示新增界面
- handleAdd: function () {
- this.addFormVisible = true;
- this.addForm = {
- projectName: '',
- customerCompany: '',
- managerId: '',
- // userA: [],
- // userB: []
- };
- },
- //新增
- addSubmit: function () {
- this.$refs.addForm.validate((valid) => {
- if (valid) {
- // console.log(this.addForm)
- // var userIds = "";
- // if(this.addForm.userA.length != 0){
- // for(var i in this.addForm.userA){
- // userIds += this.addForm.userA[i] + ","
- // }
- // }
-
- // if(this.addForm.userB.length != 0){
- // for(var i in this.addForm.userB){
- // userIds += this.addForm.userB[i] + ","
- // }
- // }
-
- // userIds = userIds.substring(0,userIds.length-1)
- var cId = "",
- cName = "";
- for(var i in this.addForm.customerCompany){
- console.log(this.addForm.customerCompany[i])
- cId += this.addForm.customerCompany[i].id + ",";
- cName += this.addForm.customerCompany[i].companyName + ",";
- }
- cId = cId.substring(0,cId.length-1);
- cName = cName.substring(0,cName.length-1);
- this.addLoading = true;
- this.http.post(this.port.project.addProject, {
- projectName: this.addForm.projectName,
- customerCompanyIds: cId,
- customerCompanyNames: cName,
- managerName: this.addForm.managerId.username,
- managerId: this.addForm.managerId.id,
- // userIds: userIds,
- flag: 0
- } , res => {
- this.addLoading = false;
- this.addFormVisible = false;
- if (res.code == "ok") {
- this.$message({
- message: '创建成功',
- type: 'success'
- });
- this.getProject();
- } else {
- this.$message({
- message: res.msg,
- type: 'error'
- });
- }
- }, error => {
- this.addLoading = false;
- this.addFormVisible = false;
- this.$message({
- message: error,
- type: 'error'
- });
- })
- }
- });
- },
- //删除
- // handleDel: function (index, row) {
- // this.$confirm('确认删除该记录吗?', '提示', {
- // type: 'warning'
- // }).then(() => {
- // this.listLoading = true;
- // let para = { id: row.id };
- // removeUser(para).then((res) => {
- // this.listLoading = false;
- // this.$message({
- // message: '删除成功',
- // type: 'success'
- // });
- // this.getProject();
- // });
- // }).catch(() => {
- // });
- // }
- },
- created() {
- let height = window.innerHeight;
- this.tableHeight = height - 210;
- },
- mounted() {
- this.getMsg();
- this.getProject();
- }
- }
- </script>
- <style scoped>
- </style>
|