123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367 |
- <template>
- <section >
- <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
- <el-form :inline="true">
- <el-form-item :label="user.timeType.customDegreeName + $t('guan-li')">
- </el-form-item>
- <!-- <el-link type="primary" :underline="false" @click="intoCenterRatio" class="tanjia">批量导入{{user.timeType.customDegreeName}}</el-link>
- <el-link icon="el-icon-circle-plus-outline" type="primary" :underline="false" class="tanjia" @click="addNewSubProject()">添加{{user.timeType.customDegreeName}}</el-link>
- <el-link type="primary" :underline="false" @click="batchDelete" class="tanjia">批量删除{{user.timeType.customDegreeName}}</el-link> -->
- <el-link type="primary" :underline="false" @click="batchDelete" class="tanjia">{{ $t('Batchdelete') }}</el-link>
- <el-link type="primary" :underline="false" @click="outoCenterRatio" class="tanjia">{{ $t('Exportdata') }}</el-link>
- <el-link type="primary" :underline="false" @click="intoCenterRatio" class="tanjia">{{ $t('bulkimport') }}</el-link>
- <el-link icon="el-icon-circle-plus-outline" type="primary" :underline="false" class="tanjia" @click="addNewSubProject()">{{ $t('add') }}</el-link>
- </el-form>
- </el-col>
- <el-table :data="subProjectList" highlight-current-row v-loading="listLoading" :height="heightDoms" style="width: 100%;" @selection-change="selectionChange">
- <el-table-column type="selection"></el-table-column>
- <el-table-column prop="id" width="200" :label="$t('headerTop.serialNumber')" align="center">
- <template slot-scope="scope" >
- {{scope.$index + 1}}
- </template>
- </el-table-column>
- <el-table-column prop="name" :label="$t('names')" width="160" show-overflow-tooltip></el-table-column>
- <el-table-column prop="projectNum" :label="$t('numberofrelatedprojects')" width="160">
- <template slot-scope="scope">{{scope.row.projectNum + $t('ge')}}</template>
- </el-table-column>
- <el-table-column prop="projects" :label="$t('relatedprojects')" min-width="180" show-overflow-tooltip></el-table-column>
- <el-table-column prop="rmark" :label="$t('bei-zhu')" min-width="180" show-overflow-tooltip></el-table-column>
- <el-table-column :label="$t('operation')" width="170">
- <template slot-scope="scope" >
- <el-button size="small" type="primary" @click="addNewSubProject(scope.row)">{{ $t('bian-ji') }}</el-button>
- <el-button size="small" type="danger" @click="deleteSubPro(scope.row)">{{ $t('btn.delete') }}</el-button>
- </template>
- </el-table-column>
- </el-table>
- <el-dialog :title="$t('addedormodifiedthemaintenancedata')" v-if="addSubProject" :visible.sync="addSubProject" :close-on-click-modal="false" customClass="customWidth" width="600px">
- <el-form ref="form2" :model="addfm" :rules="ruless" label-width="100px">
- <el-form-item :label="$t('names')" prop="name">
- <el-input v-model="addfm.name" :placeholder="$t('peaseenterthe')" clearable></el-input>
- </el-form-item>
- <el-form-item :label="$t('bei-zhu')">
- <el-input type="textarea" :rows="4" :placeholder="$t('peaseenterthe')" v-model="addfm.rmark" clearable maxlength="150" show-word-limit> </el-input>
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button @click.native="addSubProject = false">{{ $t('btn.cancel') }}</el-button>
- <el-button type="primary" @click="submitInsertSubProject" :loading="addLoading">{{ $t('btn.submit') }}</el-button>
- </div>
- </el-dialog>
- <!-- 导入结果说明 -->
- <el-dialog :title="$t('importtheresults')" v-if="showImportResult" :visible.sync="showImportResult" customClass="customWidth" width="500px">
- <div>
- <span>{{importResultMsg}}</span>
-
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button type="primary" @click="showImportResult=false">{{ $t('btn.determine') }}</el-button>
- </span>
- </el-dialog>
- <!-- <span>{{ $t('importTemplate') }}</span> -->
- <el-dialog :title="$t('dao-ru') + user.timeType.customDegreeName + $t('shu-ju')" v-if="intoCenterDialog" :visible.sync="intoCenterDialog" customClass="customWidth" width="500px">
- <p>1. {{ $t('other.download') }}
- <el-link type="primary" style="margin-left:5px;" :underline="false" href="./upload/研究中心导入模板.xlsx" :download="user.timeType.customDegreeName+ $t('importTemplate') +'.xlsx'">{{user.timeType.customDegreeName + $t('importTemplate')}}.xlsx</el-link>
- </p>
- <!-- <p>2. 填写excel模板,请确保模板中的项目和人员已添加到系统中。</p> -->
- <p style="display: flex;justify-content: center;padding:1em 0">
- <el-upload ref="upload" action="#" :limit="1" :http-request="batchImportData" :show-file-list="false">
- <el-button type="primary" :underline="false" :loading="importingData">{{ $t('other.startImporting') }}</el-button>
- </el-upload>
- </p>
- </el-dialog>
- </section>
- </template>
- <script>
- export default {
- data() {
- return {
- user: JSON.parse(sessionStorage.getItem("user")),
- subProjectList: [],//子项目列表
- listLoading: false,
- addfm: {
- name: '',
- rmark: ''
- },
- addSubProject: false,
- ruless: {
- name: [{ required: true, message: this.$t('pleaseentername'), trigger: "blur" }],
- },
- heightDoms: document.documentElement.clientHeight - 140,
- intoCenterDialog:false,
- importingData: false,
- importResultMsg:null,
- showImportResult:false,
- selectionArr: []
- };
- },
- methods: {
- // 批量删除
- selectionChange(selection){
- this.selectionArr = selection
- console.log(this.selectionArr);
- },
- batchDelete(){
- if(this.selectionArr.length == 0){
- this.$message(this.$t('pleaseselectheonesyouwanttodelete') + this.user.timeType.customDegreeName + this.$t('shu-ju'))
- return
- }else{
- let nametext = ''
- for(let i in this.selectionArr){
- nametext += this.selectionArr[i].name + '、'
- }
- nametext = nametext.substring(0,nametext.length - 1)
- this.$confirm(this.$t('makesuretodeleteinbatches') + this.user.timeType.customDegreeName + this.$t('shu-ju') +':' + nametext + '\u3000' + $t('ma'),this.$t('btn.delete'),{
- confirmButtonText: this.$t('btn.determine'),
- cancelButtonText: this.$t('btn.cancel'),
- type: 'warning'
- }).then(()=>{
- let batchIds = ''
- for(let m in this.selectionArr){
- batchIds += this.selectionArr[m].id + ','
- }
- batchIds = batchIds.substring(0,batchIds.length - 1)
- this.http.post('/report-extra-degree/batchDelete',{
- batchIds
- },res => {
- if(res.code == 'ok'){
- this.$message({
- message: this.$t('message.successfullyDeleted'),
- type: 'success'
- })
- this.getSub()
- }else {
- this.$message({
- message: res.msg,
- type: 'error'
- })
- }
- },err => {
- this.$message({
- message: err,
- type: 'error'
- })
- })
- })
- }
- },
- intoCenterRatio(){
- this.intoCenterDialog=true;
- },
- outoCenterRatio(){
- this.http.post('/report-extra-degree/exportData',{},
- res => {
- if(res.code == 'ok'){
- let filePath = res.data;
- let fileName = filePath.split('/upload/')[1]
- const a = document.createElement('a'); // 创建a标签
- a.setAttribute('download', fileName);// download属性
- a.setAttribute('href', filePath);// href链接
- a.click(); //自执行点击事件
- a.remove();
- }else{
- this.$message({
- message: res.msg,
- type: 'error'
- })
- }
- },err => {
- this.$message({
- message: err,
- type: 'error'
- })
- })
- },
- batchImportData(item) {
- //首先判断文件类型
- let str = item.file.name.split(".");
- let format = str[str.length - 1];
- if (format != "xls" && format != "xlsx") {
- this.$message({
- message: this.$t('other.PleaseselecttheXLSorXLSXfile'),
- type: "error"
- });
- } else {
- this.importingData = true;
- let formData = new FormData();
- formData.append("file", item.file);
- this.http.uploadFile('/report-extra-degree/importData', formData,
- res => {
- this.$refs.upload.clearFiles();
- this.importingData = false;
- this.showImportResult = true;
- if (res.code == "ok") {
- //换成弹出框,以免有人等了半天回来啥也没看到
- this.importResultMsg = this.$t('importedupdatedsuccessfully')+res.data+this.$t('customersdata')+"。"+(res.msg?res.msg:"");
- this.getSub();
- } else {
- this.importResultMsg = this.$t('export.Importfailure') + ":"+res.msg;
- }
- },
- error => {
- this.$refs.upload.clearFiles();
- this.importingData = false;
- this.$message({
- message: error,
- type: "error"
- });
- });
- }
- },
- getSub() {
- this.listLoading = true;
- this.http.post('/report-extra-degree/getAll ',{withProjects:1},
- res => {
- this.listLoading = false;
- if (res.code == "ok") {
- console.log(res, '看看')
- this.subProjectList = res.data
- } else {
- this.$message({
- message: res.msg,
- type: "error"
- });
- }
- },
- error => {
- this.listLoading = false;
- this.$message({
- message: error,
- type: "error"
- });
- }
- );
- },
- addNewSubProject(subProject) {
- // console.log(1234)
- // if (subProject == null) {
- // this.addForm = {projectId: this.currentProject.id, level:1}
- // }
- // else {
- // this.addForm = subProject;
- // }
- if(subProject) {
- this.addfm.name = subProject.name
- this.addfm.id = subProject.id
- this.addfm.rmark = subProject.rmark
- } else {
- this.addfm = {name: '',rmark: ''}
- }
- this.addSubProject = true;
- },
- deleteSubPro(subProject) {
- this.$confirm(this.$t('makesuretodeletethisone') + subProject.name + this.$t('shu-ju'),this.$t('btn.delete'), {
- confirmButtonText: this.$t('btn.determine'),
- cancelButtonText: this.$t('btn.cancel'),
- type: "warning"
- })
- .then(() => {
- this.listLoading = true;
- this.http.post('/report-extra-degree/delete',{
- id: subProject.id
- },
- res => {
- this.listLoading = false;
- if (res.code == "ok") {
- this.$message({
- message: this.$t('message.successfullyDeleted'),
- type: "success"
- });
- this.getSub();
- } else {
-
- this.$message({
- message: res.msg,
- type: "error"
- });
-
- }
- },
- error => {
- this.listLoading = false;
- this.$message({
- message: error,
- type: "error"
- });
- }
- );
- })
- .catch(() => {});
- },
- submitInsertSubProject() {
- this.$refs.form2.validate(valid => {
- if (valid) {
- var slp = this.addfm
- this.http.post('/report-extra-degree/addOrMod',slp,
- res => {
- this.listLoading = false;
- if (res.code == "ok") {
- this.$message({
- message: this.$t('other.successful'),
- type: "success"
- });
- this.addfm = {name: '',rmark: ''}
- this.addSubProject = false
- this.getSub()
- } else {
- this.$message({
- message: res.msg,
- type: "error"
- });
- }
- },
- error => {
- this.listLoading = false;
- this.$message({
- message: error,
- type: "error"
- });
- }
- );
- }
- })
- },
- },
- created() {
- this.getSub()
- },
- mounted() {
- }
- };
- </script>
- <style lang="scss" scoped>
- .addNode {
- cursor:pointer;
- }
- .addNode:hover {
- color:#20a0ff;
- }
- .panel {
- padding:30px 15px ;box-shadow: 0 2px 4px rgba(3, 3, 3, 0.12), 0 0 6px rgba(0, 0, 0, .04);
-
- }
- .sample {
- margin-top:30px;
- color: #999;
- }
- .tip {
- margin-left:10px; color:gray;
-
- }
- .tanjia {
- float: right;
- box-sizing: border-box;
- margin: 10px 28px;
- }
- </style>
- <style>
- .el-tooltip__popper{
- max-width: 600px;
- }
- </style>
|