Overview.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. <template>
  2. <section class="content">
  3. <div class="box box-info">
  4. <div
  5. class="box-body"
  6. v-loading.body="loading"
  7. v-loading.fullscreen="loading"
  8. element-loading-text="请稍后..."
  9. >
  10. <!-- 表单 -->
  11. <el-form inline :model="formSearch">
  12. <el-form-item label="项目名称">
  13. <el-input
  14. placeholder="请输入项目名称"
  15. v-model="formSearch.name"
  16. style="width: 180px"
  17. />
  18. </el-form-item>
  19. <el-form-item>
  20. <el-button
  21. size="small"
  22. type="primary"
  23. icon="el-icon-search"
  24. @click="handleSearchBtn"
  25. >
  26. 查询
  27. </el-button>
  28. </el-form-item>
  29. </el-form>
  30. <div class="block-seperator"></div>
  31. <!-- 页面列表 -->
  32. <el-table
  33. :data="tableData"
  34. border
  35. resizable
  36. stripe
  37. style="width: 100%;"
  38. >
  39. <el-table-column width="50" label="ID">
  40. <span slot-scope="scope">{{ scope.row.id }}</span>
  41. </el-table-column>
  42. <el-table-column prop="name" label="项目名称"> </el-table-column>
  43. <el-table-column width="90" prop="analyseTypeName" label="分析类型">
  44. </el-table-column>
  45. <el-table-column width="90" prop="orgCount" label="中心数量">
  46. </el-table-column>
  47. <el-table-column width="90" prop="courseCount" label="课程数量">
  48. </el-table-column>
  49. <el-table-column width="90" prop="passScore" label="及格线">
  50. </el-table-column>
  51. <el-table-column width="90" prop="partitionCount" label="分段数量">
  52. </el-table-column>
  53. <el-table-column width="90" prop="reportStatusName" label="项目状态">
  54. </el-table-column>
  55. <el-table-column :context="_self" label="操作" width="380">
  56. <div slot-scope="scope">
  57. <el-button
  58. size="mini"
  59. type="primary"
  60. plain
  61. :disabled="disSetScore(scope.row)"
  62. @click="openEdtDialog(scope.row)"
  63. >
  64. 分段设定
  65. </el-button>
  66. <el-button
  67. v-if="scope.row.reportStatus == 'NONE'"
  68. size="mini"
  69. type="primary"
  70. plain
  71. @click="doCompute(scope.row)"
  72. >
  73. 开始统计
  74. </el-button>
  75. <el-button
  76. v-if="scope.row.reportStatus != 'NONE'"
  77. size="mini"
  78. type="primary"
  79. plain
  80. :disabled="disReCompute(scope.row)"
  81. @click="doCompute(scope.row)"
  82. >
  83. 重新统计
  84. </el-button>
  85. <el-button
  86. size="mini"
  87. type="primary"
  88. :disabled="disViewReport(scope.row)"
  89. plain
  90. @click="viewReport(scope.row.id)"
  91. >
  92. 查看报表
  93. </el-button>
  94. <el-button
  95. size="mini"
  96. type="primary"
  97. plain
  98. @click="viewComputeJob(scope.row.id)"
  99. >
  100. 计算详情
  101. </el-button>
  102. </div>
  103. </el-table-column>
  104. </el-table>
  105. <div class="page pull-right">
  106. <el-pagination
  107. v-if="paginationShow"
  108. @current-change="handleCurrentChange"
  109. :current-page="currentPage"
  110. :page-size="pageSize"
  111. :page-sizes="[10, 20, 50, 100, 200, 300]"
  112. @size-change="handleSizeChange"
  113. layout="total, sizes, prev, pager, next, jumper"
  114. :total="total"
  115. />
  116. </div>
  117. </div>
  118. <el-dialog
  119. title="及格线及分数段设定"
  120. width="600px"
  121. :visible.sync="model"
  122. :close-on-click-modal="false"
  123. @close="closeModel"
  124. >
  125. <el-form
  126. :inline="true"
  127. :model="projectForm"
  128. ref="projectForm"
  129. :rules="rules"
  130. label-width="90px"
  131. :key="modelKey"
  132. class="editForm"
  133. >
  134. <el-row
  135. ><span style="color:#F00" v-if="projectForm.reportStatus != 'NONE'"
  136. >重新设定分数将会删除当前项目已生成的报表数据并重新计算!</span
  137. ></el-row
  138. >
  139. <el-row>
  140. <el-form-item label="满分" prop="totalScore" class="form-item">
  141. <el-input-number
  142. size="mini"
  143. v-model="projectForm.totalScore"
  144. :precision="1"
  145. :step="0.5"
  146. :min="1"
  147. :max="1000"
  148. ></el-input-number>
  149. </el-form-item>
  150. <el-form-item label="及格分" prop="passScore" class="form-item">
  151. <el-input-number
  152. size="mini"
  153. v-model="projectForm.passScore"
  154. :precision="1"
  155. :step="0.5"
  156. :min="0.5"
  157. :max="projectForm.totalScore"
  158. ></el-input-number>
  159. </el-form-item>
  160. </el-row>
  161. <el-row> <span>分段区域设定</span> </el-row>
  162. <div class="block-seperator"></div>
  163. <el-row>
  164. <el-form-item
  165. label="分数段"
  166. prop="partitionDetails"
  167. class="form-item"
  168. >
  169. <span style="width: 100px; display: inline-block;">
  170. <el-button
  171. v-if="projectForm.partitionDetails.length == 0"
  172. type="primary"
  173. size="mini"
  174. plain
  175. @click="addPartition(0)"
  176. >新增分数段</el-button
  177. >
  178. </span>
  179. </el-form-item>
  180. </el-row>
  181. <el-row>
  182. <div
  183. class="partition-main-left-div"
  184. v-if="projectForm.partitionDetails.length > 0"
  185. >
  186. <div
  187. class="partition-detail-div"
  188. v-for="(item, index) in projectForm.partitionDetails"
  189. :key="index"
  190. >
  191. <span style="min-width: 20px; display: inline-block;">
  192. 间断{{ index + 1 }}:
  193. </span>
  194. <el-input-number
  195. size="mini"
  196. v-model="projectForm.partitionDetails[index]"
  197. :precision="1"
  198. :step="0.5"
  199. :min="0.5"
  200. :max="projectForm.totalScore - 0.5"
  201. ></el-input-number>
  202. <el-button
  203. :disabled="projectForm.partitionDetails.length == 1"
  204. style="margin: 0 0 0 30px;"
  205. type="danger"
  206. circle
  207. size="mini"
  208. icon="el-icon-minus"
  209. @click="delPartition(index)"
  210. ></el-button>
  211. <el-button
  212. circle
  213. size="mini"
  214. icon="el-icon-plus"
  215. @click="addPartition(index + 1)"
  216. ></el-button>
  217. </div>
  218. </div>
  219. <div
  220. class="partition-main-rigth-div"
  221. v-if="projectForm.partitionDetails.length > 0"
  222. >
  223. <div
  224. class="partition-detail-div"
  225. v-for="(item, index) in projectForm.partitionDetails"
  226. :key="index"
  227. >
  228. <span style="min-width: 20px; display: inline-block;">
  229. <div v-if="index == 0">
  230. 0&lt;=分数&lt;{{ projectForm.partitionDetails[index] }}
  231. </div>
  232. <div
  233. v-if="
  234. index > 0 && index < projectForm.partitionDetails.length
  235. "
  236. >
  237. {{ projectForm.partitionDetails[index - 1] }}&lt;=分数&lt;{{
  238. projectForm.partitionDetails[index]
  239. }}
  240. </div>
  241. <div v-if="index == projectForm.partitionDetails.length - 1">
  242. {{ projectForm.partitionDetails[index] }}&lt;=分数&lt;={{
  243. projectForm.totalScore
  244. }}
  245. </div>
  246. </span>
  247. </div>
  248. </div></el-row
  249. >
  250. <el-row class="pull-center">
  251. <el-button
  252. type="primary"
  253. @click="sub"
  254. :loading="this.projectForm.loading"
  255. >确定</el-button
  256. >
  257. <el-button @click="closeModel">取消</el-button>
  258. </el-row>
  259. </el-form>
  260. </el-dialog>
  261. </div>
  262. </section>
  263. </template>
  264. <script>
  265. import { REPORTS_API } from "@/constants/constants.js";
  266. import { mapState } from "vuex";
  267. export default {
  268. name: "Overview",
  269. data() {
  270. return {
  271. loading: false,
  272. model: false,
  273. modelKey: Math.random(),
  274. paginationShow: false,
  275. formSearch: {
  276. name: "",
  277. enable: true
  278. },
  279. projectForm: {
  280. reportStatus: "",
  281. passScore: 0.0,
  282. totalScore: 0.0,
  283. partitionDetails: [],
  284. id: null,
  285. partitionCount: 0,
  286. loading: false
  287. },
  288. tableData: [],
  289. currentPage: 1,
  290. pageSize: 10,
  291. total: 10,
  292. rules: {
  293. passScore: [
  294. { required: true, message: "请输入及格分数", trigger: "change" }
  295. ],
  296. totalScore: [
  297. { required: true, message: "请输入满分分数", trigger: "change" }
  298. ],
  299. partitionDetails: [
  300. {
  301. required: true,
  302. type: "array",
  303. message: "请设置分数段",
  304. trigger: "change"
  305. }
  306. ]
  307. }
  308. };
  309. },
  310. computed: {
  311. ...mapState({ user: state => state.user }),
  312. isSuperAdmin() {
  313. return this.user.roleList.some(role => role.roleCode == "SUPER_ADMIN");
  314. }
  315. },
  316. methods: {
  317. getStatus() {
  318. let doingIds = this.getDoingId();
  319. if (doingIds != "") {
  320. this.$httpWithoutBar
  321. .get(REPORTS_API + "/project/getProjectList?ids=" + doingIds)
  322. .then(response => {
  323. response.data.forEach(element => {
  324. this.tableData.forEach(e => {
  325. if (e.id == element.id) {
  326. e.reportStatus = element.reportStatus;
  327. e.reportStatusName = element.reportStatusName;
  328. }
  329. });
  330. });
  331. setTimeout(() => {
  332. this.getStatus();
  333. }, 5000);
  334. });
  335. }
  336. },
  337. getDoingId() {
  338. var tempData = [];
  339. this.tableData.forEach(element => {
  340. if (
  341. element.reportStatus == "WAITCOMPUTE" ||
  342. element.reportStatus == "COMPUTING"
  343. ) {
  344. tempData.push(element.id);
  345. }
  346. });
  347. return tempData.join(",");
  348. },
  349. doCompute(row) {
  350. this.loading = true;
  351. let url = REPORTS_API + "/project/compute/" + row.id;
  352. this.$httpWithMsg
  353. .post(url)
  354. .then(() => {
  355. this.$notify({
  356. type: "success",
  357. message: "操作成功!"
  358. });
  359. this.searchForm();
  360. })
  361. .finally(() => (this.loading = false));
  362. },
  363. delPartition(index) {
  364. this.projectForm.partitionDetails.splice(index, 1);
  365. },
  366. addPartition(index) {
  367. if (index == 0) {
  368. this.projectForm.partitionDetails.splice(index, 0, 0.5);
  369. this.$refs.projectForm.validate();
  370. } else {
  371. this.projectForm.partitionDetails.splice(
  372. index,
  373. 0,
  374. this.projectForm.partitionDetails[index - 1] + 0.5
  375. );
  376. }
  377. },
  378. disSetScore(row) {
  379. if (
  380. row.reportStatus == "WAITCOMPUTE" ||
  381. row.reportStatus == "COMPUTING"
  382. ) {
  383. return true;
  384. } else {
  385. return false;
  386. }
  387. },
  388. viewReport(projectId) {
  389. this.$router.push({
  390. path: "/reports/report-view/" + projectId
  391. });
  392. },
  393. viewComputeJob(projectId) {
  394. this.$router.push({
  395. path: "/reports/compute-job-list/" + projectId
  396. });
  397. },
  398. disViewReport(row) {
  399. if (row.reportStatus != "SUCCESS") {
  400. return true;
  401. } else {
  402. return false;
  403. }
  404. },
  405. disReCompute(row) {
  406. if (
  407. row.reportStatus == "NONE" ||
  408. row.reportStatus == "WAITCOMPUTE" ||
  409. row.reportStatus == "COMPUTING"
  410. ) {
  411. return true;
  412. } else {
  413. return false;
  414. }
  415. },
  416. openEdtDialog(row) {
  417. this.modelKey = Math.random();
  418. this.projectForm = Object.assign({}, row);
  419. if (this.projectForm.partitionDetails == null) {
  420. this.projectForm.partitionDetails = [];
  421. }
  422. this.model = true;
  423. },
  424. async sub() {
  425. const res = await this.$refs.projectForm.validate();
  426. if (res === false) {
  427. return;
  428. }
  429. this.projectForm.loading = true;
  430. let url = REPORTS_API + "/project/updateScore";
  431. this.$httpWithMsg
  432. .post(url, this.projectForm)
  433. .then(() => {
  434. this.$notify({
  435. type: "success",
  436. message: "保存成功!"
  437. });
  438. this.closeModel();
  439. this.searchForm();
  440. })
  441. .finally(() => (this.projectForm.loading = false));
  442. },
  443. closeModel() {
  444. this.model = false;
  445. this.$refs.projectForm.resetFields();
  446. this.modelKey = Math.random();
  447. },
  448. handleSearchBtn() {
  449. this.currentPage = 1;
  450. this.searchForm();
  451. },
  452. handleSizeChange(val) {
  453. this.pageSize = val;
  454. this.currentPage = 1;
  455. this.searchForm();
  456. },
  457. handleCurrentChange(val) {
  458. this.currentPage = val;
  459. this.searchForm();
  460. },
  461. //查询
  462. searchForm() {
  463. this.loading = true;
  464. var url =
  465. REPORTS_API + "/project/page/" + this.currentPage + "/" + this.pageSize;
  466. this.$httpWithMsg
  467. .get(url, { params: this.formSearch })
  468. .then(response => {
  469. this.tableData = response.data.list;
  470. this.total = response.data.total;
  471. this.loading = false;
  472. this.$nextTick(function() {
  473. this.paginationShow = true;
  474. });
  475. this.getStatus();
  476. })
  477. .finally(() => (this.loading = false));
  478. },
  479. init() {
  480. this.searchForm();
  481. }
  482. },
  483. //初始化查询
  484. created() {
  485. this.init();
  486. }
  487. };
  488. </script>
  489. <style scoped>
  490. .page {
  491. margin-top: 10px;
  492. }
  493. .pull-length {
  494. width: 100px;
  495. }
  496. .details-length {
  497. width: 400px;
  498. }
  499. .pull-center {
  500. margin-top: 20px;
  501. }
  502. .editForm .el-form-item {
  503. margin-bottom: 12px;
  504. }
  505. .partition-main-left-div {
  506. width: 300px;
  507. padding: 5px;
  508. float: left;
  509. border: 1px solid #ddd;
  510. margin-left: 5px;
  511. }
  512. .partition-main-rigth-div {
  513. width: 200px;
  514. padding: 5px;
  515. float: right;
  516. border: 1px solid #ddd;
  517. margin-right: 5px;
  518. }
  519. .partition-detail-div {
  520. margin-top: 5px;
  521. }
  522. </style>