index.vue 13.9 KB
<template>
	<div class="NCC-common-layout">
		<div class="NCC-common-layout-center">
			<el-row class="NCC-common-search-box" :gutter="16">
				<el-form @submit.native.prevent>
					<el-col :span="6">
						<el-form-item label="项目名称">
							<el-input v-model="query.fullName" placeholder="项目名称" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="签订时间">
							<el-date-picker v-model="query.signingTime" type="daterange" value-format="timestamp" format="yyyy-MM-dd" start-placeholder="开始日期" end-placeholder="结束日期">
							</el-date-picker>
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="项目经理">
							<userSelect v-model="query.desPerson" placeholder="请选择项目经理" />
						</el-form-item>
					</el-col>
					<template v-if="showAll">
					<el-col :span="6">
						<el-form-item label="项目类型">
							<el-select v-model="query.itemType" placeholder="项目类型" clearable >
								<el-option v-for="(item, index) in itemTypeOptions" :key="index" :label="item.fullName" :value="item.id"  />
							</el-select>
						</el-form-item>
					</el-col>
					</template>
					<el-col :span="6">
						<el-form-item>
							<el-button type="primary" icon="el-icon-search" @click="search()">查询</el-button>
							<el-button icon="el-icon-refresh-right" @click="reset()">重置</el-button>
							<el-button type="text" icon="el-icon-arrow-down" @click="showAll=true" v-if="!showAll">展开</el-button>
							<el-button type="text" icon="el-icon-arrow-up" @click="showAll=false" v-else>收起</el-button>
						</el-form-item>
					</el-col>
				</el-form>
			</el-row>
			<div class="NCC-common-layout-main NCC-flex-main">
				<div class="NCC-common-head">
					<div>
						<el-button type="primary" icon="el-icon-plus" @click="addOrUpdateHandle()">新增</el-button>
						<el-button type="text" icon="el-icon-download" @click="exportData()">导出</el-button>
					</div>
					<div class="NCC-common-head-right">
						<el-tooltip effect="dark" content="刷新" placement="top">
							<el-link icon="icon-ym icon-ym-Refresh NCC-common-head-icon" :underline="false" @click="reset()" />
						</el-tooltip>
						<screenfull :isContainer="true" />
					</div>
				</div>
				 <NCC-table v-loading="listLoading" :data="list" :header-cell-style="{'text-align':'center'}">
					<el-table-column prop="fullName" label="项目名称/项目编码"  show-overflow-tooltip width="340">
                     <template slot-scope="scope">
                         <p>{{ scope.row.fullName }}</p>
                         <p class="text-grey">{{ scope.row.enCode }}</p>
                      </template>
                    </el-table-column>
					<el-table-column prop="startTime" label="开始日期/结束日期"  align="center"  width="140">
                        <template slot-scope="scope" algin="center"  >
                        <p class="text-warning">{{ scope.row.startTime | toDate("yyyy-MM-dd") }}</p>
                        <p class="text-success">{{scope.row.endTime | toDate("yyyy-MM-dd") }}</p>
                        </template>
                    </el-table-column>
					<el-table-column prop="schedule" label="项目工期/完成进度"  width="160">
                     <template slot-scope="scope">
                         <p>{{ scope.row.timeLimit }}天</p>
                         <el-progress :percentage="scope.row.schedule" :color="customColorMethod"></el-progress>
                      </template>
                     </el-table-column>
					<el-table-column label="项目类型/项目金额(元)"  prop="itemType" align="center" width="180">
						<template slot-scope="scope">
                           <p> {{ scope.row.itemType | dynamicText(itemTypeOptions) }}</p>
						 <p><el-tag type="success">{{ scope.row.amount | currency('¥') }}</el-tag></p>
                     </template>
                     </el-table-column>
					<el-table-column label="项目阶段/签订时间"  prop="stage" align="center" width="160">
						<template slot-scope="scope">
                            <p> {{ scope.row.stage | dynamicText(stageOptions) }}</p>
                            <p class="text-primary">{{scope.row.signingTime | toDate("yyyy-MM-dd") }}</p>
                        </template>
					</el-table-column>
					 <el-table-column prop="managerIds" label="项目经理/参与人员" width="260">
                      <template slot-scope="scope">
						 <p>项目经理:<el-tag type="warning">{{ scope.row.desPerson }}</el-tag></p>
                        <el-avatar :size="30" :src="define.comUrl+img.headIcon"
                          v-for="(img,i) in scope.row.managersInfo" :key="i" :title="img.account"
                              style="margin-right: 6px;margin-top:8px;"></el-avatar>
                     </template>
					 </el-table-column>
					<el-table-column label="客户名称"  prop="customer" align="left" >
						<template slot-scope="scope">{{ scope.row.customer | dynamicText(customerOptions) }}</template>
					</el-table-column>
					<el-table-column prop="creatorUserId" label="创建用户/创建时间" align="center"  width="140">
                        <template slot-scope="scope" algin="center" >
                        <p>{{ scope.row.creatorUserId }}</p>
                        <p class="text-grey">{{scope.row.creatorTime | toDate("yyyy-MM-dd HH:mm") }}</p>
                        </template>
                    </el-table-column>
					<el-table-column label="操作" fixed="right" width="200">
						<template slot-scope="scope">
							<el-button type="text" @click="addOrUpdateHandle(scope.row.id)"  v-has="'btn_edit'">
								编辑
							</el-button>
							<el-button type="text" @click="handleDel(scope.row.id)" class="NCC-table-delBtn" v-has="'btn_remove'">
								删除
							</el-button>
                              <el-button type="text"  @click="addOrUpdateHandle(scope.row.id,true)" v-has="'btn_detail'"  >
                                详细
                            </el-button>
                             <el-button size="mini" type="text" @click="toTask(scope.row)" v-has="'btn_task'">项目任务</el-button>
						</template>
					</el-table-column>
				</NCC-table>
                <pagination :total="total" :page.sync="listQuery.currentPage" :limit.sync="listQuery.pageSize" @pagination="initData" />
            </div>
        </div>
		<NCC-Form v-if="formVisible" ref="NCCForm" @refresh="refresh" />
		<ExportBox v-if="exportBoxVisible" ref="ExportBox" @download="download" />
        <Task v-show="taskVisible" ref="task" @close="taskVisible=false" />
	</div>
</template>
<script>
    import request from '@/utils/request'
    import { getDictionaryDataSelector } from '@/api/systemData/dictionary'
    import NCCForm from './Form'
    import ExportBox from './ExportBox'
    import Task from './Task'
    import { previewDataInterface } from '@/api/systemData/dataInterface'
	export default {
        components: { NCCForm, ExportBox,Task },
        data() {
            return {
                showAll: false,
				query: {
                    fullName:undefined,
                    signingTime:undefined,
                    desPerson:undefined,
                    itemType:undefined,
				},
                list: [],
                listLoading: true,
                multipleSelection: [], total: 0,
                listQuery: {
                    currentPage: 1,
                    pageSize: 20,
					sort: "desc",
                    sidx: "",
                },
                formVisible: false,
                exportBoxVisible: false,
                taskVisible:false,
                columnList: [
                    { prop: 'enCode', label: '项目编号' },
                    { prop: 'fullName', label: '项目名称' },
                    { prop: 'amount', label: '项目金额' },
                    { prop: 'signingTime', label: '签订时间' },
                    { prop: 'stage', label: '项目阶段' },
                    { prop: 'startTime', label: '开始时间' },
                    { prop: 'endTime', label: '结束时间' },
                    { prop: 'timeLimit', label: '项目工期' },
                    { prop: 'schedule', label: '完成进度' },
                    { prop: 'desPerson', label: '项目经理' },
                    { prop: 'managerIds', label: '参与人员' },
                    { prop: 'customer', label: '客户名称' },
                    { prop: 'creatorUserId', label: '创建用户' },
                    { prop: 'creatorTime', label: '创建时间' },
                    { prop: 'itemType', label: '项目类型' },
				],
				itemTypeOptions : [],
				stageOptions : [],
				stateOptions : [],
				customerOptions : [],
			}
        },
		computed: {},
		created() {
			this.initData()
			this.getitemTypeOptions();
			this.getstageOptions();
			this.getstateOptions();
			this.getcustomerOptions();
		},
		methods: {
            customColorMethod(percentage) {
        if (percentage < 20) {
          return '#909399';
        } else if (percentage < 50) {
          return '#FF3333';
        } else if (percentage < 70) {
          return '#e6a23c';
        }else if (percentage < 90) {
          return '#00FF00';
        }  else {
          return '#67c23a';
        }
      },
      increase() {
        this.percentage += 10;
        if (this.percentage > 100) {
          this.percentage = 100;
        }
      },
      decrease() {
        this.percentage -= 10;
        if (this.percentage < 0) {
          this.percentage = 0;
        }
      },
			getitemTypeOptions(){
				getDictionaryDataSelector('0fd534ef4423481f8a3c2bfc87de8943').then(res => {
					this.itemTypeOptions = res.data.list
				});
			},
			getstageOptions(){
				getDictionaryDataSelector('90e5b20bd000435aad8cd4b669dccfec').then(res => {
					this.stageOptions = res.data.list
				});
			},
			getstateOptions(){
				getDictionaryDataSelector('2b32fa4cc6b340af80f55f046b0432e3').then(res => {
					this.stateOptions = res.data.list
				});
			},
			getcustomerOptions(){
				previewDataInterface('195029830188664069').then(res => {
					this.customerOptions = res.data
				});
			},
			sortChange({ column, prop, order }) {
                this.listQuery.sort = order == 'ascending' ? 'asc' : 'desc'
                this.listQuery.sidx = !order ? '' : prop
                this.initData()
			},
			initData() {
                this.listLoading = true;
                let _query = {
                    ...this.listQuery,
                    ...this.query
                };
                let query = {}
                for (let key in _query) {
                    if (Array.isArray(_query[key])) {
                        query[key] = _query[key].join()
                    } else {
                        query[key] = _query[key]
                    }
                }
                request({
                    url: `/api/SubDev/ZyOaProjectgantt`,
                    method: 'GET',
                    data: query
                }).then(res => {
                    this.list = res.data.list
                    this.total = res.data.pagination.total
                    this.listLoading = false
                })
            },
			handleDel(id) {
                this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
                    type: 'warning'
                }).then(() => {
                    request({
                        url: `/api/SubDev/ZyOaProjectgantt/${id}`,
                        method: 'DELETE'
                    }).then(res => {
                        this.$message({
                            type: 'success',
                            message: res.msg,
                            onClose: () => {
                                this.initData()
                            }
                        });
                    })
                }).catch(() => {
                });
            },
			addOrUpdateHandle(id, isDetail) {
                this.formVisible = true
                this.$nextTick(() => {
                    this.$refs.NCCForm.init(id, isDetail)
                })
            },
			exportData() {
                this.exportBoxVisible = true
                this.$nextTick(() => {
                    this.$refs.ExportBox.init(this.columnList)
                })
            },
            download(data) {
                let query = { ...data, ...this.listQuery, ...this.query }
                request({
                    url: `/api/SubDev/ZyOaProjectgantt/Actions/Export`,
                    method: 'GET',
                    data: query
                }).then(res => {
                    if (!res.data.url) return
                    window.location.href = this.define.comUrl + res.data.url
                    this.$refs.ExportBox.visible = false
                    this.exportBoxVisible = false
                })
            },
            toTask(row) {
                this.taskVisible = true
                this.$nextTick(() => {
                this.$refs.task.init(row)
              })
             },
			search() {
                this.listQuery = {
                    currentPage: 1,
                    pageSize: 20,
                    sort: "desc",
                    sidx: "creatorTime",
                }
                this.initData()
            },
            refresh(isrRefresh) {
                this.formVisible = false
                if (isrRefresh) this.reset()
            },
            reset() {
                for (let key in this.query) {
                    this.query[key] = undefined
                }
                this.listQuery = {
                    currentPage: 1,
                    pageSize: 20,
                    sort: "desc",
                    sidx: "creatorTime",
                }
                this.initData()
            }
		}
    }
</script>
<style lang="scss" scoped>
.managerImg {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  margin-right: 6px;
}
</style>