centerManage.vue 17 KB

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