centerManage.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. <template>
  2. <section>
  3. <el-select v-model="value" filterable placeholder="请选择" :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="请输入关键名称" 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()">搜索</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: '选项1',
  123. label: '黄金糕'
  124. }, {
  125. value: '选项2',
  126. label: '双皮奶'
  127. }, {
  128. value: '选项3',
  129. label: '蚵仔煎'
  130. }, {
  131. value: '选项4',
  132. label: '龙须面'
  133. }, {
  134. value: '选项5',
  135. label: '北京烤鸭'
  136. }],
  137. value: ''
  138. };
  139. },
  140. methods: {
  141. aabbcc() {
  142. console.log(12345)
  143. },
  144. searchName() {
  145. var val = this.searchNameVal
  146. let arr = []
  147. if (val) {
  148. arr = this.subProjectListArr.filter((num) => {
  149. if (num.name.indexOf(val) != '-1') {
  150. return num
  151. }
  152. })
  153. this.subProjectList = arr
  154. } else {
  155. this.subProjectList = this.subProjectListArr
  156. }
  157. },
  158. // 批量删除
  159. selectionChange(selection) {
  160. this.selectionArr = selection
  161. console.log(this.selectionArr);
  162. },
  163. batchDelete() {
  164. if (this.selectionArr.length == 0) {
  165. this.$message(this.$t('pleaseselectheonesyouwanttodelete') + this.user.timeType.customDegreeName + this.$t('shu-ju'))
  166. return
  167. } else {
  168. let nametext = ''
  169. for (let i in this.selectionArr) {
  170. nametext += this.selectionArr[i].name + '、'
  171. }
  172. nametext = nametext.substring(0, nametext.length - 1)
  173. this.$confirm(this.$t('makesuretodeleteinbatches') + this.user.timeType.customDegreeName + this.$t('shu-ju') + ':' + nametext + '\u3000' + $t('ma'), this.$t('btn.delete'), {
  174. confirmButtonText: this.$t('btn.determine'),
  175. cancelButtonText: this.$t('btn.cancel'),
  176. type: 'warning'
  177. }).then(() => {
  178. let batchIds = ''
  179. for (let m in this.selectionArr) {
  180. batchIds += this.selectionArr[m].id + ','
  181. }
  182. batchIds = batchIds.substring(0, batchIds.length - 1)
  183. this.http.post('/report-extra-degree/batchDelete', {
  184. batchIds
  185. }, res => {
  186. if (res.code == 'ok') {
  187. this.$message({
  188. message: this.$t('message.successfullyDeleted'),
  189. type: 'success'
  190. })
  191. this.getSub()
  192. } else {
  193. this.$message({
  194. message: res.msg,
  195. type: 'error'
  196. })
  197. }
  198. }, err => {
  199. this.$message({
  200. message: err,
  201. type: 'error'
  202. })
  203. })
  204. })
  205. }
  206. },
  207. intoCenterRatio() {
  208. this.intoCenterDialog = true;
  209. },
  210. outoCenterRatio() {
  211. this.http.post('/report-extra-degree/exportData', {},
  212. res => {
  213. if (res.code == 'ok') {
  214. let filePath = res.data;
  215. let fileName = filePath.split('/upload/')[1]
  216. const a = document.createElement('a'); // 创建a标签
  217. a.setAttribute('download', fileName);// download属性
  218. a.setAttribute('href', filePath);// href链接
  219. a.click(); //自执行点击事件
  220. a.remove();
  221. } else {
  222. this.$message({
  223. message: res.msg,
  224. type: 'error'
  225. })
  226. }
  227. }, err => {
  228. this.$message({
  229. message: err,
  230. type: 'error'
  231. })
  232. })
  233. },
  234. batchImportData(item) {
  235. //首先判断文件类型
  236. let str = item.file.name.split(".");
  237. let format = str[str.length - 1];
  238. if (format != "xls" && format != "xlsx") {
  239. this.$message({
  240. message: this.$t('other.PleaseselecttheXLSorXLSXfile'),
  241. type: "error"
  242. });
  243. } else {
  244. this.importingData = true;
  245. let formData = new FormData();
  246. formData.append("file", item.file);
  247. this.http.uploadFile('/report-extra-degree/importData', formData,
  248. res => {
  249. this.$refs.upload.clearFiles();
  250. this.importingData = false;
  251. this.showImportResult = true;
  252. if (res.code == "ok") {
  253. //换成弹出框,以免有人等了半天回来啥也没看到
  254. this.importResultMsg = this.$t('importedupdatedsuccessfully') + res.data + this.$t('customersdata') + "。" + (res.msg ? res.msg : "");
  255. this.getSub();
  256. } else {
  257. this.importResultMsg = this.$t('export.Importfailure') + ":" + res.msg;
  258. }
  259. },
  260. error => {
  261. this.$refs.upload.clearFiles();
  262. this.importingData = false;
  263. this.$message({
  264. message: error,
  265. type: "error"
  266. });
  267. });
  268. }
  269. },
  270. getSub() {
  271. this.listLoading = true;
  272. this.http.post('/report-extra-degree/getAll ', { withProjects: 1 },
  273. res => {
  274. this.listLoading = false;
  275. if (res.code == "ok") {
  276. console.log(res, '看看')
  277. this.subProjectList = res.data
  278. this.subProjectListArr = res.data
  279. } else {
  280. this.$message({
  281. message: res.msg,
  282. type: "error"
  283. });
  284. }
  285. },
  286. error => {
  287. this.listLoading = false;
  288. this.$message({
  289. message: error,
  290. type: "error"
  291. });
  292. }
  293. );
  294. },
  295. addNewSubProject(subProject) {
  296. // console.log(1234)
  297. // if (subProject == null) {
  298. // this.addForm = {projectId: this.currentProject.id, level:1}
  299. // }
  300. // else {
  301. // this.addForm = subProject;
  302. // }
  303. if (subProject) {
  304. this.addfm.name = subProject.name
  305. this.addfm.id = subProject.id
  306. this.addfm.rmark = subProject.rmark
  307. } else {
  308. this.addfm = { name: '', rmark: '' }
  309. }
  310. this.addSubProject = true;
  311. },
  312. deleteSubPro(subProject) {
  313. this.$confirm(this.$t('makesuretodeletethisone') + subProject.name + this.$t('shu-ju'), this.$t('btn.delete'), {
  314. confirmButtonText: this.$t('btn.determine'),
  315. cancelButtonText: this.$t('btn.cancel'),
  316. type: "warning"
  317. })
  318. .then(() => {
  319. this.listLoading = true;
  320. this.http.post('/report-extra-degree/delete', {
  321. id: subProject.id
  322. },
  323. res => {
  324. this.listLoading = false;
  325. if (res.code == "ok") {
  326. this.$message({
  327. message: this.$t('message.successfullyDeleted'),
  328. type: "success"
  329. });
  330. this.getSub();
  331. } else {
  332. this.$message({
  333. message: res.msg,
  334. type: "error"
  335. });
  336. }
  337. },
  338. error => {
  339. this.listLoading = false;
  340. this.$message({
  341. message: error,
  342. type: "error"
  343. });
  344. }
  345. );
  346. })
  347. .catch(() => { });
  348. },
  349. submitInsertSubProject() {
  350. this.$refs.form2.validate(valid => {
  351. if (valid) {
  352. var slp = this.addfm
  353. this.http.post('/report-extra-degree/addOrMod', slp,
  354. res => {
  355. this.listLoading = false;
  356. if (res.code == "ok") {
  357. this.$message({
  358. message: this.$t('other.successful'),
  359. type: "success"
  360. });
  361. this.addfm = { name: '', rmark: '' }
  362. this.addSubProject = false
  363. this.getSub()
  364. } else {
  365. this.$message({
  366. message: res.msg,
  367. type: "error"
  368. });
  369. }
  370. },
  371. error => {
  372. this.listLoading = false;
  373. this.$message({
  374. message: error,
  375. type: "error"
  376. });
  377. }
  378. );
  379. }
  380. })
  381. },
  382. },
  383. created() {
  384. this.getSub()
  385. },
  386. mounted() {
  387. }
  388. };
  389. </script>
  390. <style lang="scss" scoped>
  391. .addNode {
  392. cursor: pointer;
  393. }
  394. .addNode:hover {
  395. color: #20a0ff;
  396. }
  397. .panel {
  398. padding: 30px 15px;
  399. box-shadow: 0 2px 4px rgba(3, 3, 3, 0.12), 0 0 6px rgba(0, 0, 0, .04);
  400. }
  401. .sample {
  402. margin-top: 30px;
  403. color: #999;
  404. }
  405. .tip {
  406. margin-left: 10px;
  407. color: gray;
  408. }
  409. .tanjia {
  410. float: right;
  411. box-sizing: border-box;
  412. margin: 10px 28px;
  413. }
  414. </style>
  415. <style>
  416. .el-tooltip__popper {
  417. max-width: 600px;
  418. }
  419. </style>