centerManage.vue 17 KB

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