centerManage.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. <template>
  2. <section>
  3. <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
  4. <el-form :inline="true">
  5. <el-form-item label="岗位" style="width: 200px">
  6. <el-select v-model="searchPosition" :placeholder="$t('defaultText.pleaseChoose')" clearable style="width: 160px" size="small">
  7. <el-option v-for="option in positionList" :label="option.name" :value="option.name" :key="option.id">
  8. </el-option>
  9. </el-select>
  10. </el-form-item>
  11. <el-form-item :label="user.timeType.customDegreeName + $t('guan-li')">
  12. <el-input :placeholder="$t('qing-shu-ru-guan-jian-ming-cheng')" v-model.trim="searchNameVal" clearable class="input-with-select" size="small"
  13. style="margin-left: 50px" @keyup.enter.native="searchName()">
  14. <el-button slot="append" @click="searchName()">{{ $t('sou-suo') }}</el-button>
  15. </el-input>
  16. </el-form-item>
  17. <!-- <el-link type="primary" :underline="false" @click="intoCenterRatio" class="tanjia">批量导入{{user.timeType.customDegreeName}}</el-link>
  18. <el-link icon="el-icon-circle-plus-outline" type="primary" :underline="false" class="tanjia" @click="addNewSubProject()">添加{{user.timeType.customDegreeName}}</el-link>
  19. <el-link type="primary" :underline="false" @click="batchDelete" class="tanjia">批量删除{{user.timeType.customDegreeName}}</el-link> -->
  20. <!---->
  21. <el-link type="primary" :underline="false" @click="batchDelete" class="tanjia">{{ $t('Batchdelete')
  22. }}</el-link>
  23. <el-link type="primary" :underline="false" @click="outoCenterRatio" class="tanjia">{{ $t('Exportdata')
  24. }}</el-link>
  25. <el-link type="primary" :underline="false" @click="intoCenterRatio" class="tanjia">{{ $t('bulkimport')
  26. }}</el-link>
  27. <el-link icon="el-icon-circle-plus-outline" type="primary" :underline="false" class="tanjia"
  28. @click="addNewSubProject()">{{ $t('add') }}</el-link>
  29. </el-form>
  30. </el-col>
  31. <el-table :data="filteredSubProjectList" highlight-current-row v-loading="listLoading" :height="heightDoms"
  32. style="width: 100%;" @selection-change="selectionChange">
  33. <el-table-column type="selection"></el-table-column>
  34. <el-table-column prop="id" width="200" :label="$t('headerTop.serialNumber')" align="center">
  35. <template slot-scope="scope">
  36. {{ scope.$index + 1 }}
  37. </template>
  38. </el-table-column>
  39. <el-table-column prop="name" :label="$t('names')" width="160" show-overflow-tooltip></el-table-column>
  40. <el-table-column v-if="!zhengbeiCompanysId.includes(user.companyId)" prop="projectNum" :label="$t('numberofrelatedprojects')" width="160">
  41. <template slot-scope="scope">{{ scope.row.projectNum + $t('ge') }}</template>
  42. </el-table-column>
  43. <el-table-column v-if="!zhengbeiCompanysId.includes(user.companyId)" prop="projects" :label="$t('relatedprojects')" min-width="180"
  44. show-overflow-tooltip></el-table-column>
  45. <el-table-column v-if="zhengbeiCompanysId.includes(user.companyId)" label="岗位" min-width="180" prop="position"
  46. show-overflow-tooltip>
  47. </el-table-column>
  48. <el-table-column prop="rmark" :label="$t('bei-zhu')" min-width="180" show-overflow-tooltip></el-table-column>
  49. <el-table-column :label="$t('operation')" width="170">
  50. <template slot-scope="scope">
  51. <el-button size="small" type="primary" @click="addNewSubProject(scope.row)">{{ $t('bian-ji')
  52. }}</el-button>
  53. <el-button size="small" type="danger" @click="deleteSubPro(scope.row)">{{ $t('btn.delete')
  54. }}</el-button>
  55. </template>
  56. </el-table-column>
  57. </el-table>
  58. <el-dialog :title="$t('addedormodifiedthemaintenancedata')" v-if="addSubProject" :visible.sync="addSubProject"
  59. :close-on-click-modal="false" customClass="customWidth" width="600px">
  60. <el-form ref="form2" :model="addfm" :rules="ruless" label-width="100px">
  61. <el-form-item :label="$t('names')" prop="name">
  62. <el-input v-model="addfm.name" :placeholder="$t('peaseenterthe')" clearable></el-input>
  63. </el-form-item>
  64. <el-form-item v-if = "zhengbeiCompanysId.includes(user.companyId)" label="岗位" prop="departmentIdList">
  65. <el-select v-model="addfm.positionArray" :placeholder="$t('defaultText.pleaseChoose')" multiple clearable style="width: 100%">
  66. <el-option v-for="option in positionList" :label="option.name" :value="option.name" :key="option.id">
  67. </el-option>
  68. </el-select>
  69. </el-form-item>
  70. <el-form-item :label="$t('bei-zhu')">
  71. <el-input type="textarea" :rows="4" :placeholder="$t('peaseenterthe')" v-model="addfm.rmark" clearable
  72. maxlength="150" show-word-limit> </el-input>
  73. </el-form-item>
  74. </el-form>
  75. <div slot="footer" class="dialog-footer">
  76. <el-button @click.native="addSubProject = false">{{ $t('btn.cancel') }}</el-button>
  77. <el-button type="primary" @click="submitInsertSubProject" :loading="addLoading">{{ $t('btn.submit')
  78. }}</el-button>
  79. </div>
  80. </el-dialog>
  81. <!-- 导入结果说明 -->
  82. <el-dialog :title="$t('importtheresults')" v-if="showImportResult" :visible.sync="showImportResult"
  83. customClass="customWidth" width="500px">
  84. <div>
  85. <span>{{ importResultMsg }}</span>
  86. </div>
  87. <span slot="footer" class="dialog-footer">
  88. <el-button type="primary" @click="showImportResult = false">{{ $t('btn.determine') }}</el-button>
  89. </span>
  90. </el-dialog>
  91. <!-- <span>{{ $t('importTemplate') }}</span> -->
  92. <el-dialog :title="$t('dao-ru') + user.timeType.customDegreeName + $t('shu-ju')" v-if="intoCenterDialog"
  93. :visible.sync="intoCenterDialog" customClass="customWidth" width="500px">
  94. <p>1. {{ $t('other.download') }}
  95. <el-link type="primary" style="margin-left:5px;" :underline="false" :href="downloadHref"
  96. :download="user.timeType.customDegreeName + $t('importTemplate') + '.xlsx'">{{
  97. user.timeType.customDegreeName
  98. + $t('importTemplate') }}.xlsx</el-link>
  99. </p>
  100. <!-- <p>2. 填写excel模板,请确保模板中的项目和人员已添加到系统中。</p> -->
  101. <p style="display: flex;justify-content: center;padding:1em 0">
  102. <el-upload ref="upload" action="#" :limit="1" :http-request="batchImportData" :show-file-list="false">
  103. <el-button type="primary" :underline="false" :loading="importingData">{{ $t('other.startImporting')
  104. }}</el-button>
  105. </el-upload>
  106. </p>
  107. </el-dialog>
  108. </section>
  109. </template>
  110. <script>
  111. export default {
  112. computed:{
  113. //过滤筛选结果
  114. filteredSubProjectList(){
  115. const list = this.subProjectList
  116. let result = []
  117. if(!this.searchPosition || !this.subProjectList){
  118. return list
  119. }
  120. for(const item of list){
  121. if (item.position && item.position.indexOf(this.searchPosition) >= 0) {
  122. result.push(item)
  123. }
  124. }
  125. return result
  126. },
  127. downloadHref() {
  128. const companyId = this.user.companyId
  129. const zhengbeiCompanysIdList = this.zhengbeiCompanysId
  130. for(const id of zhengbeiCompanysIdList){
  131. if(id == companyId){
  132. return "./upload/正北/工作内容导入模板.xlsx"
  133. }
  134. }
  135. return "./upload/工作内容导入模板.xlsx"
  136. },
  137. },
  138. data() {
  139. return {
  140. user: JSON.parse(sessionStorage.getItem("user")),
  141. listLoading: false,
  142. addfm: {
  143. name: '',
  144. rmark: '',
  145. position:'',
  146. positionArray:[],
  147. },
  148. addSubProject: false,
  149. ruless: {
  150. name: [{ required: true, message: this.$t('pleaseentername'), trigger: "blur" }],
  151. },
  152. heightDoms: document.documentElement.clientHeight - 140,
  153. intoCenterDialog: false,
  154. importingData: false,
  155. importResultMsg: null,
  156. showImportResult: false,
  157. selectionArr: [],
  158. subProjectList: [],//子项目列表
  159. subProjectListArr: [], // 备用列表
  160. searchNameVal: '',
  161. searchPosition:'',
  162. options: [],
  163. value: '',
  164. zhengbeiCompanysId:[8138,8261,8264,8268]
  165. };
  166. },
  167. methods: {
  168. aabbcc() {
  169. console.log(12345)
  170. },
  171. handleCascaderChange(value){
  172. if (!value || value.length === 0) {
  173. this.searchDepartmentId = null
  174. }
  175. },
  176. searchName() {
  177. var val = this.searchNameVal
  178. let arr = []
  179. if (val) {
  180. arr = this.subProjectListArr.filter((num) => {
  181. if (num.name.indexOf(val) != '-1') {
  182. return num
  183. }
  184. })
  185. this.subProjectList = arr
  186. } else {
  187. this.subProjectList = this.subProjectListArr
  188. }
  189. },
  190. // 批量删除
  191. selectionChange(selection) {
  192. this.selectionArr = selection
  193. console.log(this.selectionArr);
  194. },
  195. batchDelete() {
  196. if (this.selectionArr.length == 0) {
  197. this.$message(this.$t('pleaseselectheonesyouwanttodelete') + this.user.timeType.customDegreeName + this.$t('shu-ju'))
  198. return
  199. } else {
  200. let nametext = ''
  201. for (let i in this.selectionArr) {
  202. nametext += this.selectionArr[i].name + '、'
  203. }
  204. nametext = nametext.substring(0, nametext.length - 1)
  205. this.$confirm(this.$t('makesuretodeleteinbatches') + this.user.timeType.customDegreeName + this.$t('shu-ju') + ':' + nametext + '\u3000' + this.$t('ma'), this.$t('btn.delete'), {
  206. confirmButtonText: this.$t('btn.determine'),
  207. cancelButtonText: this.$t('btn.cancel'),
  208. type: 'warning'
  209. }).then(() => {
  210. let batchIds = ''
  211. for (let m in this.selectionArr) {
  212. batchIds += this.selectionArr[m].id + ','
  213. }
  214. batchIds = batchIds.substring(0, batchIds.length - 1)
  215. this.http.post('/report-extra-degree/batchDelete', {
  216. batchIds
  217. }, res => {
  218. if (res.code == 'ok') {
  219. this.$message({
  220. message: this.$t('message.successfullyDeleted'),
  221. type: 'success'
  222. })
  223. this.getSub()
  224. } else {
  225. this.$message({
  226. message: res.msg,
  227. type: 'error'
  228. })
  229. }
  230. }, err => {
  231. this.$message({
  232. message: err,
  233. type: 'error'
  234. })
  235. })
  236. })
  237. }
  238. },
  239. intoCenterRatio() {
  240. this.intoCenterDialog = true;
  241. },
  242. outoCenterRatio() {
  243. const list = this.filteredSubProjectList
  244. this.http.JSONPost('/report-extra-degree/exportData', list,
  245. res => {
  246. if (res.code == 'ok') {
  247. let filePath = res.data;
  248. let fileName = filePath.split('/upload/')[1]
  249. const a = document.createElement('a'); // 创建a标签
  250. a.setAttribute('download', fileName);// download属性
  251. a.setAttribute('href', filePath);// href链接
  252. a.click(); //自执行点击事件
  253. a.remove();
  254. } else {
  255. this.$message({
  256. message: res.msg,
  257. type: 'error'
  258. })
  259. }
  260. }, err => {
  261. this.$message({
  262. message: err,
  263. type: 'error'
  264. })
  265. })
  266. },
  267. batchImportData(item) {
  268. //首先判断文件类型
  269. let str = item.file.name.split(".");
  270. let format = str[str.length - 1];
  271. if (format != "xls" && format != "xlsx") {
  272. this.$message({
  273. message: this.$t('other.PleaseselecttheXLSorXLSXfile'),
  274. type: "error"
  275. });
  276. } else {
  277. this.importingData = true;
  278. let formData = new FormData();
  279. formData.append("file", item.file);
  280. this.http.uploadFile('/report-extra-degree/importData', formData,
  281. res => {
  282. this.$refs.upload.clearFiles();
  283. this.importingData = false;
  284. this.showImportResult = true;
  285. if (res.code == "ok") {
  286. //换成弹出框,以免有人等了半天回来啥也没看到
  287. this.importResultMsg = this.$t('importedupdatedsuccessfully') + res.data + this.$t('customersdata') + "。" + (res.msg ? res.msg : "");
  288. this.getSub();
  289. } else {
  290. this.importResultMsg = this.$t('export.Importfailure') + ":" + res.msg;
  291. }
  292. },
  293. error => {
  294. this.$refs.upload.clearFiles();
  295. this.importingData = false;
  296. this.$message({
  297. message: error,
  298. type: "error"
  299. });
  300. });
  301. }
  302. },
  303. getPositionList() {
  304. var userCustomName = '岗位';
  305. this.http.post('/sub-user-custom/listWithName ', {userCustomName},
  306. res => {
  307. this.listLoading = false;
  308. if (res.code == "ok") {
  309. this.positionList = res.data
  310. } else {
  311. this.$message({
  312. message: res.msg,
  313. type: "error"
  314. });
  315. }
  316. },
  317. error => {
  318. this.listLoading = false;
  319. this.$message({
  320. message: error,
  321. type: "error"
  322. });
  323. }
  324. );
  325. },
  326. getSub() {
  327. this.listLoading = true;
  328. this.http.post('/report-extra-degree/getAll ', { withProjects: 1 },
  329. res => {
  330. this.listLoading = false;
  331. if (res.code == "ok") {
  332. this.subProjectList = res.data
  333. this.subProjectListArr = res.data
  334. } else {
  335. this.$message({
  336. message: res.msg,
  337. type: "error"
  338. });
  339. }
  340. },
  341. error => {
  342. this.listLoading = false;
  343. this.$message({
  344. message: error,
  345. type: "error"
  346. });
  347. }
  348. );
  349. },
  350. addNewSubProject(subProject) {
  351. // console.log(1234)
  352. // if (subProject == null) {
  353. // this.addForm = {projectId: this.currentProject.id, level:1}
  354. // }
  355. // else {
  356. // this.addForm = subProject;
  357. // }
  358. if (subProject) {
  359. this.addfm.name = subProject.name
  360. this.addfm.id = subProject.id
  361. this.addfm.rmark = subProject.rmark
  362. this.addfm.positionArray = subProject.position.split(",")
  363. } else {
  364. this.addfm = { name: '', rmark: '' ,positionArray:[]}
  365. }
  366. this.addSubProject = true;
  367. },
  368. deleteSubPro(subProject) {
  369. this.$confirm(this.$t('makesuretodeletethisone') + subProject.name + this.$t('shu-ju'), this.$t('btn.delete'), {
  370. confirmButtonText: this.$t('btn.determine'),
  371. cancelButtonText: this.$t('btn.cancel'),
  372. type: "warning"
  373. })
  374. .then(() => {
  375. this.listLoading = true;
  376. this.http.post('/report-extra-degree/delete', {
  377. id: subProject.id
  378. },
  379. res => {
  380. this.listLoading = false;
  381. if (res.code == "ok") {
  382. this.$message({
  383. message: this.$t('message.successfullyDeleted'),
  384. type: "success"
  385. });
  386. this.getSub();
  387. } else {
  388. this.$message({
  389. message: res.msg,
  390. type: "error"
  391. });
  392. }
  393. },
  394. error => {
  395. this.listLoading = false;
  396. this.$message({
  397. message: error,
  398. type: "error"
  399. });
  400. }
  401. );
  402. })
  403. .catch(() => { });
  404. },
  405. submitInsertSubProject() {
  406. this.$refs.form2.validate(valid => {
  407. if (valid) {
  408. var slp = this.addfm
  409. if(this.addfm.positionArray){
  410. slp.position = this.addfm.positionArray.join(',');
  411. }
  412. else{
  413. slp.position = ''
  414. }
  415. this.http.post('/report-extra-degree/addOrMod', slp,
  416. res => {
  417. this.listLoading = false;
  418. if (res.code == "ok") {
  419. this.$message({
  420. message: this.$t('other.successful'),
  421. type: "success"
  422. });
  423. this.addfm = { name: '', rmark: '',positionArray:[] }
  424. this.addSubProject = false
  425. this.getSub()
  426. } else {
  427. this.$message({
  428. message: res.msg,
  429. type: "error"
  430. });
  431. }
  432. },
  433. error => {
  434. this.listLoading = false;
  435. this.$message({
  436. message: error,
  437. type: "error"
  438. });
  439. }
  440. );
  441. }
  442. })
  443. },
  444. // 修改数组
  445. changeArr(arr) {
  446. for (var i = 0; i < arr.length; i++) {
  447. if (arr[i].id != -1 && arr[i].id != 0) {
  448. if (arr[i].children != null && arr[i].children.length > 0) {
  449. arr[i].children = this.changeArr(arr[i].children);
  450. }
  451. arr[i].id && (arr[i].value = arr[i].id);
  452. delete arr[i].id;
  453. }
  454. }
  455. for (var i in arr) {
  456. if (arr[i].id == -1 || arr[i].id == 0) {
  457. arr.splice(i, 1);
  458. }
  459. }
  460. return arr;
  461. },
  462. },
  463. created() {
  464. this.getSub()
  465. },
  466. mounted() {
  467. this.getPositionList();
  468. }
  469. };
  470. </script>
  471. <style lang="scss" scoped>
  472. @import "../../assets/scss/handle";
  473. .themeFontColor {
  474. @include font_color("color");
  475. }
  476. .addNode {
  477. cursor: pointer;
  478. }
  479. .addNode:hover {
  480. @include font_color("color");
  481. }
  482. .panel {
  483. padding: 30px 15px;
  484. box-shadow: 0 2px 4px rgba(3, 3, 3, 0.12), 0 0 6px rgba(0, 0, 0, .04);
  485. }
  486. .sample {
  487. margin-top: 30px;
  488. color: #999;
  489. }
  490. .tip {
  491. margin-left: 10px;
  492. color: gray;
  493. }
  494. .tanjia {
  495. float: right;
  496. box-sizing: border-box;
  497. margin: 10px 28px;
  498. }
  499. </style>
  500. <style>
  501. .el-tooltip__popper {
  502. max-width: 600px;
  503. }
  504. </style>