| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530 |
- <template>
- <section>
- <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
- <el-form :inline="true">
- <el-form-item label="岗位" style="width: 200px">
- <el-select v-model="searchPosition" :placeholder="$t('defaultText.pleaseChoose')" clearable style="width: 160px" size="small">
- <el-option v-for="option in positionList" :label="option.name" :value="option.name" :key="option.id">
- </el-option>
- </el-select>
- </el-form-item>
-
-
- <el-form-item :label="user.timeType.customDegreeName + $t('guan-li')">
- <el-input :placeholder="$t('qing-shu-ru-guan-jian-ming-cheng')" v-model.trim="searchNameVal" clearable class="input-with-select" size="small"
- style="margin-left: 50px" @keyup.enter.native="searchName()">
- <el-button slot="append" @click="searchName()">{{ $t('sou-suo') }}</el-button>
- </el-input>
- </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="filteredSubProjectList" 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 v-if="!zhengbeiCompanysId.includes(user.companyId)" prop="projectNum" :label="$t('numberofrelatedprojects')" width="160">
- <template slot-scope="scope">{{ scope.row.projectNum + $t('ge') }}</template>
- </el-table-column>
- <el-table-column v-if="!zhengbeiCompanysId.includes(user.companyId)" prop="projects" :label="$t('relatedprojects')" min-width="180"
- show-overflow-tooltip></el-table-column>
- <el-table-column v-if="zhengbeiCompanysId.includes(user.companyId)" label="岗位" min-width="180" prop="position"
- 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 v-if = "zhengbeiCompanysId.includes(user.companyId)" label="岗位" prop="departmentIdList">
- <el-select v-model="addfm.positionArray" :placeholder="$t('defaultText.pleaseChoose')" multiple clearable style="width: 100%">
- <el-option v-for="option in positionList" :label="option.name" :value="option.name" :key="option.id">
- </el-option>
- </el-select>
- </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="downloadHref"
- :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 {
- computed:{
- //过滤筛选结果
- filteredSubProjectList(){
- const list = this.subProjectList
- let result = []
- if(!this.searchPosition || !this.subProjectList){
- return list
- }
- for(const item of list){
- if (item.position && item.position.indexOf(this.searchPosition) >= 0) {
- result.push(item)
- }
- }
- return result
- },
- downloadHref() {
-
- const companyId = this.user.companyId
- const zhengbeiCompanysIdList = this.zhengbeiCompanysId
- for(const id of zhengbeiCompanysIdList){
- if(id == companyId){
- return "./upload/正北/工作内容导入模板.xlsx"
- }
- }
- return "./upload/工作内容导入模板.xlsx"
- },
- },
- data() {
- return {
- user: JSON.parse(sessionStorage.getItem("user")),
- listLoading: false,
- addfm: {
- name: '',
- rmark: '',
- position:'',
- positionArray:[],
- },
- 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: [],
- subProjectList: [],//子项目列表
- subProjectListArr: [], // 备用列表
- searchNameVal: '',
- searchPosition:'',
- options: [],
- value: '',
- zhengbeiCompanysId:[8138,8261,8264,8268]
- };
- },
- methods: {
- aabbcc() {
- console.log(12345)
- },
- handleCascaderChange(value){
- if (!value || value.length === 0) {
- this.searchDepartmentId = null
- }
- },
- searchName() {
- var val = this.searchNameVal
- let arr = []
- if (val) {
- arr = this.subProjectListArr.filter((num) => {
- if (num.name.indexOf(val) != '-1') {
- return num
- }
- })
- this.subProjectList = arr
- } else {
- this.subProjectList = this.subProjectListArr
- }
- },
- // 批量删除
- 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' + this.$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() {
- const list = this.filteredSubProjectList
- this.http.JSONPost('/report-extra-degree/exportData', list,
- 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"
- });
- });
- }
- },
- getPositionList() {
- var userCustomName = '岗位';
- this.http.post('/sub-user-custom/listWithName ', {userCustomName},
- res => {
- this.listLoading = false;
- if (res.code == "ok") {
- this.positionList = res.data
- } else {
- this.$message({
- message: res.msg,
- type: "error"
- });
- }
- },
- error => {
- this.listLoading = 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") {
- this.subProjectList = res.data
- this.subProjectListArr = 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
- this.addfm.positionArray = subProject.position.split(",")
- } else {
- this.addfm = { name: '', rmark: '' ,positionArray:[]}
- }
- 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
- if(this.addfm.positionArray){
- slp.position = this.addfm.positionArray.join(',');
- }
- else{
- slp.position = ''
- }
- 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: '',positionArray:[] }
- this.addSubProject = false
- this.getSub()
- } else {
- this.$message({
- message: res.msg,
- type: "error"
- });
- }
- },
- error => {
- this.listLoading = false;
- this.$message({
- message: error,
- type: "error"
- });
- }
- );
- }
- })
- },
-
- // 修改数组
- changeArr(arr) {
- for (var i = 0; i < arr.length; i++) {
- if (arr[i].id != -1 && arr[i].id != 0) {
- if (arr[i].children != null && arr[i].children.length > 0) {
- arr[i].children = this.changeArr(arr[i].children);
- }
- arr[i].id && (arr[i].value = arr[i].id);
- delete arr[i].id;
- }
- }
- for (var i in arr) {
- if (arr[i].id == -1 || arr[i].id == 0) {
- arr.splice(i, 1);
- }
- }
- return arr;
- },
- },
-
-
- created() {
- this.getSub()
- },
- mounted() {
- this.getPositionList();
- }
- };
- </script>
- <style lang="scss" scoped>
- @import "../../assets/scss/handle";
- .themeFontColor {
- @include font_color("color");
- }
- .addNode {
- cursor: pointer;
- }
- .addNode:hover {
- @include font_color("color");
- }
- .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>
|