You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.vue 13 kB

2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <template>
  2. <div>
  3. <TopHeader :menu="'admin_view'"></TopHeader>
  4. <div class="ui container">
  5. <div class="top-container">
  6. <el-checkbox class="check-toggle" v-model="allChecked" @change="allSelectChange">全选/全不选</el-checkbox>
  7. <el-button class="btn-agree" @click="batchOperate(true)">批量同意展示</el-button>
  8. <el-button class="btn-cancel" @click="batchOperate(false)">批量取消展示</el-button>
  9. </div>
  10. <div class="table-container">
  11. <div class="table-title">2030科技项目管理</div>
  12. <div class="table-wrap">
  13. <el-table ref="tableRef" border :data="tableData" style="width:100%;" v-loading="loading" stripe row-key="id">
  14. <el-table-column label="" align="center" header-align="center" width="40" fixed>
  15. <template slot-scope="scope">
  16. <el-checkbox v-model="scope.row.checked" @change="rowSelectChange(scope.row)"></el-checkbox>
  17. </template>
  18. </el-table-column>
  19. <el-table-column label="启智项目名称" align="center" header-align="center" fixed min-width="150">
  20. <template slot-scope="scope">
  21. <span v-if="scope.row.status == 5">
  22. {{ `${scope.row.url.split('/')[3]}/${scope.row.url.split('/')[4]}` }}
  23. </span>
  24. <a v-else target="_blank" :href="`/${scope.row.repo_owner_name}/${scope.row.repo_name}`">
  25. {{ `${scope.row.repo_owner_name}/${scope.row.repo_name}` }}
  26. </a>
  27. </template>
  28. </el-table-column>
  29. <el-table-column prop="name" label="科技项目名称" align="center" header-align="center" fixed
  30. min-width="200"></el-table-column>
  31. <el-table-column prop="status" label="展示状态" align="center" header-align="center" fixed>
  32. <template slot-scope="scope">
  33. <span style="color:rgb(255, 37, 37)"
  34. :style="scope.row.status == 1 ? { color: 'rgb(56, 158, 13)' } : ''">{{
  35. statusMap[scope.row.status] }}</span>
  36. </template>
  37. </el-table-column>
  38. <el-table-column prop="no" label="项目立项编号" align="center" header-align="center"
  39. min-width="120"></el-table-column>
  40. <el-table-column prop="institution" label="项目承担单位" align="center" header-align="center"
  41. min-width="160"></el-table-column>
  42. <el-table-column prop="province" label="所属省(省市)" align="center" header-align="center"
  43. min-width="100"></el-table-column>
  44. <el-table-column prop="category" label="单位性质" align="center" header-align="center"
  45. min-width="120"></el-table-column>
  46. <el-table-column prop="recommend" label="推荐单位" align="center" header-align="center"
  47. min-width="120"></el-table-column>
  48. <el-table-column prop="owner" label="项目负责人" align="center" header-align="center"
  49. min-width="100"></el-table-column>
  50. <el-table-column prop="phone" label="负责人电话" align="center" header-align="center"
  51. min-width="120"></el-table-column>
  52. <el-table-column prop="email" label="负责人邮箱" align="center" header-align="center"
  53. min-width="150"></el-table-column>
  54. <el-table-column prop="contact" label="项目联系人" align="center" header-align="center"
  55. min-width="100"></el-table-column>
  56. <el-table-column prop="contact_phone" label="联系人电话" align="center" header-align="center"
  57. min-width="120"></el-table-column>
  58. <el-table-column prop="contact_email" label="联系人邮箱" align="center" header-align="center"
  59. min-width="150"></el-table-column>
  60. <el-table-column prop="apply_year" label="申报年度" align="center" header-align="center"
  61. min-width="80"></el-table-column>
  62. <el-table-column prop="execute_month" label="执行周期(月)" align="center" header-align="center"
  63. min-width="120"></el-table-column>
  64. <el-table-column prop="execute_period" label="执行期限" align="center" header-align="center"
  65. min-width="120"></el-table-column>
  66. <el-table-column prop="type" label="项目类型" align="center" header-align="center"
  67. min-width="100"></el-table-column>
  68. <el-table-column prop="start_up" label="启动会时间" align="center" header-align="center"
  69. min-width="100"></el-table-column>
  70. <el-table-column prop="number_topic" label="课题数量" align="center" header-align="center"
  71. min-width="80"></el-table-column>
  72. <el-table-column prop="topic1" label="课题一级名称及承担单位" align="center" header-align="center"
  73. min-width="200"></el-table-column>
  74. <el-table-column prop="topic2" label="课题二级名称及承担单位" align="center" header-align="center"
  75. min-width="200"></el-table-column>
  76. <el-table-column prop="topic3" label="课题三级名称及承担单位" align="center" header-align="center"
  77. min-width="200"></el-table-column>
  78. <el-table-column prop="topic4" label="课题四级名称及承担单位" align="center" header-align="center"
  79. min-width="200"></el-table-column>
  80. <el-table-column prop="topic5" label="课题五级名称及承担单位" align="center" header-align="center"
  81. min-width="200"></el-table-column>
  82. <el-table-column prop="all_institution" label="所有参与单位" align="center" header-align="center"
  83. min-width="300"></el-table-column>
  84. <el-table-column prop="contribution_institution" label="成果贡献单位" align="center" header-align="center"
  85. min-width="300"></el-table-column>
  86. <el-table-column prop="user_name" label="申请账号" align="center" header-align="center" width="120">
  87. <template slot-scope="scope">
  88. <a target="_blank" :href="`/${scope.row.user_name}`">{{
  89. `${scope.row.user_name}` }}</a>
  90. </template>
  91. </el-table-column>
  92. <el-table-column prop="" label="操作" align="center" header-align="center" fixed="right" width="100">
  93. <template slot-scope="scope">
  94. <span v-if="scope.row.status == 2" class="op-btn agree" @click="toggleStatus(scope.row)">
  95. <i class="el-icon-check"></i>
  96. <span>同意展示</span>
  97. </span>
  98. <span v-if="scope.row.status == 1" class="op-btn cancel" @click="toggleStatus(scope.row)">
  99. <i class="el-icon-close"></i>
  100. <span>取消展示</span>
  101. </span>
  102. </template>
  103. </el-table-column>
  104. </el-table>
  105. </div>
  106. <div class="op-tips">
  107. <i class="el-icon-info"></i>
  108. 提示:批量操作只会对【展示状态】为 “未展示” 或 “已展示” 的数据生效。
  109. </div>
  110. <div class="center">
  111. <el-pagination ref="paginationRef" background @current-change="currentChange" @size-change="sizeChange"
  112. :current-page.sync="page" :page-sizes="pageSizes" :page-size.sync="pageSize"
  113. layout="total, sizes, prev, pager, next, jumper" :total="total">
  114. </el-pagination>
  115. </div>
  116. </div>
  117. </div>
  118. </div>
  119. </template>
  120. <script>
  121. import TopHeader from '../components/TopHeader.vue';
  122. import { getTechAdminList, setTechAdminOperation } from '~/apis/modules/tech';
  123. export default {
  124. data() {
  125. return {
  126. allChecked: false,
  127. loading: false,
  128. tableData: [],
  129. page: 1,
  130. pageSizes: [15, 30, 50, 100],
  131. pageSize: 50,
  132. total: 0,
  133. statusMap: {
  134. '1': '已展示',
  135. '2': '未展示',
  136. '3': '项目迁移中',
  137. '4': '项目迁移失败',
  138. '5': '项目不存在',
  139. },
  140. };
  141. },
  142. components: { TopHeader },
  143. methods: {
  144. getData() {
  145. this.loading = true;
  146. getTechAdminList({
  147. page: this.page,
  148. pageSize: this.pageSize,
  149. }).then(res => {
  150. this.loading = false;
  151. const { total, data } = res.data;
  152. this.tableData = data.map((item, index) => {
  153. return {
  154. checked: false,
  155. ...item,
  156. }
  157. });
  158. this.allChecked = false;
  159. this.total = total;
  160. }).catch(err => {
  161. this.loading = false;
  162. console.log(err);
  163. });
  164. },
  165. allSelectChange() {
  166. for (let i = 0, iLen = this.tableData.length; i < iLen; i++) {
  167. this.tableData[i].checked = this.allChecked;
  168. }
  169. this.tableData.splice(1, 0);
  170. },
  171. rowSelectChange(row) {
  172. if (row.checked == false) {
  173. this.allChecked = false;
  174. } else {
  175. if (this.tableData.filter((item) => item.checked).length == this.tableData.length) {
  176. this.allChecked = true;
  177. }
  178. }
  179. this.tableData.splice(1, 0);
  180. },
  181. currentChange(page) {
  182. this.page = page;
  183. this.getData();
  184. },
  185. sizeChange(pageSize) {
  186. this.pageSize = pageSize;
  187. this.getData();
  188. },
  189. toggleStatus(row) {
  190. if (row.status != 1 && row.status != 2) return;
  191. setTechAdminOperation({
  192. type: row.status == 1 ? 'hide' : 'show',
  193. id: [row.id],
  194. }).then(res => {
  195. res = res.data;
  196. if (res.Code == 0) {
  197. this.$message({
  198. type: 'success',
  199. message: this.$t('submittedSuccessfully'),
  200. });
  201. row.status = row.status == 1 ? 2 : 1;
  202. } else {
  203. this.$message({
  204. type: 'error',
  205. message: this.$t('submittedFailed'),
  206. });
  207. }
  208. }).catch(err => {
  209. console.log(err);
  210. this.$message({
  211. type: 'error',
  212. message: this.$t('submittedFailed'),
  213. });
  214. });
  215. },
  216. batchOperate(showOr) {
  217. const selectedData = this.tableData.filter((item) => {
  218. return item.checked && item.status == (showOr ? 2 : 1);
  219. });
  220. if (!selectedData.length) {
  221. this.$message({
  222. type: 'info',
  223. message: '请选择符合条件的数据进行操作!',
  224. });
  225. return;
  226. }
  227. setTechAdminOperation({
  228. type: showOr ? 'show' : 'hide',
  229. id: selectedData.map(item => item.id),
  230. }).then(res => {
  231. res = res.data;
  232. if (res.Code == 0) {
  233. this.$message({
  234. type: 'success',
  235. message: this.$t('submittedSuccessfully'),
  236. });
  237. this.getData();
  238. } else {
  239. this.$message({
  240. type: 'error',
  241. message: this.$t('submittedFailed'),
  242. });
  243. }
  244. }).catch(err => {
  245. console.log(err);
  246. this.$message({
  247. type: 'error',
  248. message: this.$t('submittedFailed'),
  249. });
  250. });
  251. },
  252. },
  253. beforeMount() {
  254. this.getData();
  255. },
  256. mounted() { },
  257. beforeDestroy() { },
  258. };
  259. </script>
  260. <style scoped lang="less">
  261. .top-container {
  262. display: flex;
  263. align-items: center;
  264. margin: 30px 0 15px 0;
  265. .check-toggle {
  266. margin-right: 20px;
  267. }
  268. .btn-agree {
  269. margin-right: 10px;
  270. background: rgb(50, 145, 248);
  271. color: rgb(255, 255, 255);
  272. &:hover {
  273. opacity: 0.9;
  274. }
  275. &:active {
  276. opacity: 0.8;
  277. }
  278. }
  279. .btn-cancel {
  280. margin-right: 10px;
  281. background: rgb(250, 140, 22);
  282. color: rgb(255, 255, 255);
  283. &:hover {
  284. opacity: 0.9;
  285. }
  286. &:active {
  287. opacity: 0.8;
  288. }
  289. }
  290. }
  291. .table-container {
  292. .table-title {
  293. height: 43px;
  294. font-size: 16px;
  295. font-weight: 700;
  296. padding: 15px;
  297. color: rgb(16, 16, 16);
  298. border-color: rgb(212, 212, 213);
  299. border-width: 1px;
  300. border-style: solid;
  301. border-radius: 5px 5px 0px 0px;
  302. background: rgb(240, 240, 240);
  303. display: flex;
  304. align-items: center;
  305. }
  306. .table-wrap {
  307. overflow-x: auto;
  308. /deep/ .el-table__header {
  309. th {
  310. background: rgb(249, 249, 249);
  311. font-size: 12px;
  312. color: rgb(136, 136, 136);
  313. font-weight: normal;
  314. }
  315. }
  316. /deep/ .el-table__body {
  317. td {
  318. font-size: 12px;
  319. }
  320. }
  321. /deep/ .el-radio__label {
  322. display: none;
  323. }
  324. }
  325. }
  326. .op-tips {
  327. margin: 10px 0 10px 0;
  328. color: #606266;
  329. font-size: 12px;
  330. i {
  331. margin-right: 4px;
  332. }
  333. }
  334. .op-btn {
  335. cursor: pointer;
  336. &.agree {
  337. color: rgb(56, 158, 13);
  338. }
  339. &.cancel {
  340. color: rgb(50, 145, 248);
  341. }
  342. }
  343. </style>