centerManage.vue 16 KB

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