Project.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  1. <template>
  2. <section class="content" style="margin-top: 20px;">
  3. <div class="box box-info">
  4. <!-- 正文信息 -->
  5. <div class="box-body">
  6. <el-form
  7. :model="formSearch"
  8. :inline="true"
  9. label-position="right"
  10. label-width="100px"
  11. style="border-bottom: 1px solid rgb(221, 221, 221);margin-bottom: 10px"
  12. >
  13. <el-form-item label="学校">
  14. <el-select
  15. v-model="formSearch.orgId"
  16. placeholder="请选择"
  17. @change="loadExamList(formSearch.orgId)"
  18. >
  19. <el-option
  20. v-for="item in orgList"
  21. :label="item.orgName"
  22. :value="item.orgId"
  23. :key="item.orgId"
  24. ></el-option>
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item label="考试">
  28. <el-select
  29. v-model="formSearch.examId"
  30. @change="searchRecords(1)"
  31. placeholder="请选择"
  32. >
  33. <el-option
  34. v-for="item in examList"
  35. :label="item.examName"
  36. :value="item.examId"
  37. :key="item.examId"
  38. ></el-option>
  39. </el-select>
  40. </el-form-item>
  41. <el-form-item label="项目经理">
  42. <el-select
  43. v-model="formSearch.pmId"
  44. placeholder="请选择"
  45. filterable
  46. clearable
  47. remote
  48. :disabled="curUserRole.isPM"
  49. :remote-method="loadPmList"
  50. >
  51. <el-option label="请选择" value=""></el-option>
  52. <el-option
  53. v-for="item in pmList"
  54. :label="item.name"
  55. :value="item.id"
  56. :key="item.id"
  57. ></el-option>
  58. </el-select>
  59. </el-form-item>
  60. <el-form-item label="印刷供应商">
  61. <el-select
  62. v-model="formSearch.supplierId"
  63. placeholder="请选择"
  64. filterable
  65. clearable
  66. remote
  67. :disabled="curUserRole.isSupplier"
  68. :remote-method="loadSupplierList"
  69. >
  70. <el-option label="请选择" value=""></el-option>
  71. <el-option
  72. v-for="item in supplierList"
  73. :label="item.name"
  74. :value="item.id"
  75. :key="item.id"
  76. ></el-option>
  77. </el-select>
  78. </el-form-item>
  79. <el-form-item style="padding-left: 60px">
  80. <el-button
  81. size="small"
  82. v-show="false"
  83. icon="el-icon-refresh"
  84. @click="resetSearchForm"
  85. >
  86. 重置
  87. </el-button>
  88. <el-button
  89. size="small"
  90. type="primary"
  91. icon="el-icon-search"
  92. @click="searchRecords(1)"
  93. >查询
  94. </el-button>
  95. </el-form-item>
  96. </el-form>
  97. <!-- 数据列表 -->
  98. <el-table
  99. v-loading="loading"
  100. :data="tableData"
  101. element-loading-text="数据加载中"
  102. style="width:100%;"
  103. border
  104. stripe
  105. >
  106. <el-table-column
  107. width="220"
  108. label="学校名称"
  109. prop="orgName"
  110. sortable
  111. />
  112. <el-table-column label="考试名称" prop="examName" sortable />
  113. <el-table-column
  114. width="200"
  115. label="印刷供应商"
  116. prop="supplierName"
  117. sortable
  118. />
  119. <el-table-column
  120. width="150"
  121. label="项目经理"
  122. prop="pmName"
  123. sortable
  124. />
  125. <el-table-column width="120" label="项目统计">
  126. <template slot-scope="scope">
  127. <el-button
  128. size="mini"
  129. type="primary"
  130. icon="el-icon-view"
  131. @click="gotoProjectStatistic(scope.row)"
  132. plain
  133. >查看
  134. </el-button>
  135. </template>
  136. </el-table-column>
  137. <el-table-column width="120" label="操作" :context="_self">
  138. <template slot-scope="scope">
  139. <el-button
  140. size="mini"
  141. type="primary"
  142. icon="el-icon-menu"
  143. @click="openProjectSettingDialog(scope.row)"
  144. :disabled="!hasPermit"
  145. plain
  146. >项目设置
  147. </el-button>
  148. </template>
  149. </el-table-column>
  150. </el-table>
  151. <!-- 分页 -->
  152. <div class="page pull-right">
  153. <el-pagination
  154. @current-change="handlePagerNo"
  155. :current-page="formSearch.pageNo"
  156. @size-change="handlePagerSize"
  157. :page-size="formSearch.pageSize"
  158. :page-sizes="[10, 20, 50, 100]"
  159. :total="totalElements"
  160. layout="total, sizes, prev, pager, next, jumper"
  161. ></el-pagination>
  162. </div>
  163. </div>
  164. <!-- 项目设置弹窗 -->
  165. <el-dialog
  166. title="项目设置"
  167. width="700px"
  168. :visible.sync="projectSettingDialog"
  169. @close="closeProjectSettingDialog"
  170. >
  171. <el-form
  172. :model="settingForm"
  173. ref="settingForm"
  174. :rules="rules"
  175. label-position="right"
  176. label-width="110px"
  177. inline-message
  178. >
  179. <el-form-item label="学校" prop="orgId">
  180. <el-select
  181. v-model="settingForm.orgId"
  182. placeholder="请选择"
  183. :disabled="true"
  184. class="w440"
  185. >
  186. <el-option
  187. v-for="item in orgList"
  188. :label="item.orgName"
  189. :value="item.orgId"
  190. :key="item.orgId"
  191. ></el-option>
  192. </el-select>
  193. </el-form-item>
  194. <el-form-item label="考试" prop="examId">
  195. <el-select
  196. v-model="settingForm.examId"
  197. placeholder="请选择"
  198. :disabled="true"
  199. class="w440"
  200. >
  201. <el-option
  202. v-for="item in examList"
  203. :label="item.examName"
  204. :value="item.examId"
  205. :key="item.examId"
  206. ></el-option>
  207. </el-select>
  208. </el-form-item>
  209. <el-form-item label="项目经理" prop="pmId">
  210. <el-select
  211. v-model="settingForm.pmId"
  212. placeholder="请选择"
  213. @change="selectPmName"
  214. clearable
  215. class="w440"
  216. >
  217. <el-option
  218. v-for="item in pmList"
  219. :label="item.name"
  220. :value="item.id"
  221. :key="item.id"
  222. ></el-option>
  223. </el-select>
  224. </el-form-item>
  225. <el-form-item label="供应商" prop="supplierId">
  226. <el-select
  227. v-model="settingForm.supplierId"
  228. placeholder="请选择"
  229. @change="selectSupplierName"
  230. clearable
  231. class="w440"
  232. >
  233. <el-option
  234. v-for="item in supplierList"
  235. :label="item.name"
  236. :value="item.id"
  237. :key="item.id"
  238. ></el-option>
  239. </el-select>
  240. </el-form-item>
  241. <el-form-item label="准备时间" prop="prepareTimeRange">
  242. <el-date-picker
  243. v-model="prepareTimeRange"
  244. type="datetimerange"
  245. range-separator="至"
  246. start-placeholder="开始时间"
  247. end-placeholder="结束时间"
  248. :default-time="['00:00:00', '23:59:59']"
  249. >
  250. >
  251. </el-date-picker>
  252. </el-form-item>
  253. <el-form-item label="印刷时间" prop="printTimeRange">
  254. <el-date-picker
  255. v-model="printTimeRange"
  256. type="datetimerange"
  257. range-separator="至"
  258. start-placeholder="开始时间"
  259. end-placeholder="结束时间"
  260. :default-time="['00:00:00', '23:59:59']"
  261. >
  262. >
  263. </el-date-picker>
  264. </el-form-item>
  265. <el-form-item label="邮寄时间" prop="mailTimeRange">
  266. <el-date-picker
  267. v-model="mailTimeRange"
  268. type="datetimerange"
  269. range-separator="至"
  270. start-placeholder="开始时间"
  271. end-placeholder="结束时间"
  272. :default-time="['00:00:00', '23:59:59']"
  273. >
  274. >
  275. </el-date-picker>
  276. </el-form-item>
  277. </el-form>
  278. <div style="text-align: center">
  279. <el-button type="primary" @click="editProjectSetting"
  280. >确 定
  281. </el-button>
  282. <el-button @click="closeProjectSettingDialog">取 消</el-button>
  283. </div>
  284. </el-dialog>
  285. </div>
  286. </section>
  287. </template>
  288. <script>
  289. import { CORE_API, PRINT_API } from "@/constants/constants";
  290. import {} from "../constants/constants.js";
  291. import { mapState } from "vuex";
  292. import {
  293. checkEmptyStr,
  294. checkEmptyNumber,
  295. checkArray,
  296. formatGMT
  297. } from "../utils/common.js";
  298. export default {
  299. data() {
  300. let validatePrepareTimeRange = (rule, value, callback) => {
  301. if (
  302. !checkArray(this.prepareTimeRange) ||
  303. this.prepareTimeRange.length == 0
  304. ) {
  305. callback(new Error("请选择准备时间!"));
  306. } else {
  307. callback();
  308. }
  309. };
  310. let validatePrintTimeRange = (rule, value, callback) => {
  311. if (!checkArray(this.printTimeRange) || this.printTimeRange.length == 0) {
  312. callback(new Error("请选择印刷时间!"));
  313. } else {
  314. callback();
  315. }
  316. };
  317. let validateMailTimeRange = (rule, value, callback) => {
  318. if (!checkArray(this.mailTimeRange) || this.mailTimeRange.length == 0) {
  319. callback(new Error("请选择邮寄时间!"));
  320. } else {
  321. callback();
  322. }
  323. };
  324. return {
  325. formSearch: {
  326. orgId: "",
  327. examId: "",
  328. pmId: "",
  329. supplierId: "",
  330. pageNo: 1,
  331. pageSize: 10
  332. },
  333. curUserRole: {},
  334. hasPermit: false,
  335. totalElements: 0,
  336. loading: false,
  337. tableData: [],
  338. orgList: [],
  339. examList: [],
  340. pmList: [],
  341. supplierList: [],
  342. projectSettingDialog: false,
  343. settingForm: {
  344. id: "",
  345. orgId: "",
  346. examId: "",
  347. pmId: "",
  348. pmName: "",
  349. supplierId: "",
  350. supplierName: "",
  351. prepareStartTime: "",
  352. prepareEndTime: "",
  353. printStartTime: "",
  354. printEndTime: "",
  355. mailStartTime: "",
  356. mailEndTime: ""
  357. },
  358. prepareTimeRange: [],
  359. printTimeRange: [],
  360. mailTimeRange: [],
  361. rules: {
  362. orgId: [
  363. {
  364. type: "number",
  365. required: true,
  366. message: "请选择学校!",
  367. trigger: "change"
  368. }
  369. ],
  370. examId: [
  371. {
  372. type: "number",
  373. required: true,
  374. message: "请选择考试!",
  375. trigger: "change"
  376. }
  377. ],
  378. supplierId: [
  379. {
  380. required: true,
  381. message: "请选择供应商!",
  382. trigger: "change"
  383. }
  384. ],
  385. pmId: [
  386. {
  387. required: true,
  388. message: "请选择项目经理!",
  389. trigger: "change"
  390. }
  391. ],
  392. prepareTimeRange: [
  393. {
  394. required: true,
  395. validator: validatePrepareTimeRange,
  396. trigger: "change"
  397. }
  398. ],
  399. printTimeRange: [
  400. {
  401. required: true,
  402. validator: validatePrintTimeRange,
  403. trigger: "change"
  404. }
  405. ],
  406. mailTimeRange: [
  407. {
  408. required: true,
  409. validator: validateMailTimeRange,
  410. trigger: "change"
  411. }
  412. ]
  413. }
  414. };
  415. },
  416. methods: {
  417. handlePagerNo(pageNo) {
  418. /* 处理分页 */
  419. this.searchRecords(pageNo);
  420. },
  421. handlePagerSize(pageSize) {
  422. /* 处理每页条数 */
  423. this.formSearch.pageSize = pageSize;
  424. this.searchRecords(1);
  425. },
  426. resetSearchForm() {
  427. if (this.curUserRole.isPM) {
  428. this.formSearch.supplierId = "";
  429. } else if (this.curUserRole.isSupplier) {
  430. this.formSearch.pmId = "";
  431. } else {
  432. this.formSearch.pmId = "";
  433. this.formSearch.supplierId = "";
  434. }
  435. //this.searchRecords(1);
  436. },
  437. searchRecords(pageNo) {
  438. this.formSearch.pageNo = pageNo;
  439. /* 查询记录列表 */
  440. let orgId = this.formSearch.orgId;
  441. if (checkEmptyNumber(orgId)) {
  442. this.$notify({
  443. title: "提示",
  444. message: "请选择学校!",
  445. type: "warning"
  446. });
  447. return;
  448. }
  449. let examId = this.formSearch.examId;
  450. if (checkEmptyNumber(examId)) {
  451. this.$notify({
  452. title: "提示",
  453. message: "请选择考试!",
  454. type: "warning"
  455. });
  456. return;
  457. }
  458. this.loading = true;
  459. let url = PRINT_API + "/printing/project/list";
  460. this.$http.post(url, this.formSearch).then(
  461. response => {
  462. this.tableData = response.data.content;
  463. this.totalElements = response.data.totalElements;
  464. this.loading = false;
  465. },
  466. error => {
  467. console.log(error);
  468. this.loading = false;
  469. }
  470. );
  471. },
  472. selectDefault() {
  473. if (this.orgList.length > 0) {
  474. let firstOrgId = this.orgList[0].orgId;
  475. this.formSearch.orgId = firstOrgId;
  476. this.loadExamList(firstOrgId);
  477. }
  478. },
  479. loadOrgList() {
  480. /* 查询学校列表 */
  481. let url = PRINT_API + "/printing/project/org/list";
  482. this.$http.post(url).then(
  483. response => {
  484. this.orgList = response.data;
  485. this.selectDefault();
  486. },
  487. error => {
  488. console.log(error.response);
  489. // ignore
  490. }
  491. );
  492. },
  493. loadExamList(orgId) {
  494. /* 查询考试列表 */
  495. this.formSearch.examId = "";
  496. this.examList = [];
  497. this.tableData = [];
  498. if (checkEmptyNumber(orgId)) {
  499. return;
  500. }
  501. let url = PRINT_API + "/printing/project/exam/list?orgId=" + orgId;
  502. this.$http.post(url).then(response => {
  503. this.examList = response.data;
  504. if (this.examList.length > 0) {
  505. this.formSearch.examId = this.examList[0].examId;
  506. this.searchRecords(1);
  507. }
  508. });
  509. },
  510. loadPmList(query) {
  511. /* 查询项目经理列表 */
  512. this.pmList = [];
  513. let url =
  514. CORE_API +
  515. "/user/query?enable=true&rootOrgCode=qmth&roleCode=PRINT_PROJECT_LEADER";
  516. if (!checkEmptyStr(query)) {
  517. url += "&name=" + query;
  518. }
  519. this.$http.get(url).then(response => {
  520. this.pmList = response.data;
  521. });
  522. },
  523. loadSupplierList(query) {
  524. /* 查询印刷供应商列表 */
  525. this.supplierList = [];
  526. let url =
  527. CORE_API +
  528. "/user/query?enable=true&rootOrgCode=qmth-print&roleCode=PRINT_SUPPLIER";
  529. if (!checkEmptyStr(query)) {
  530. url += "&name=" + query;
  531. }
  532. this.$http.get(url).then(response => {
  533. this.supplierList = response.data;
  534. });
  535. },
  536. loadPmInfo(loginUser) {
  537. this.pmList = [];
  538. this.pmList.push({ id: loginUser.userId, name: loginUser.displayName });
  539. },
  540. loadSupplierInfo(loginUser) {
  541. this.supplierList = [];
  542. this.supplierList.push({
  543. id: loginUser.userId,
  544. name: loginUser.displayName
  545. });
  546. },
  547. selectPmName(key) {
  548. /* 处理项目经理名称 */
  549. if (checkEmptyNumber(key)) {
  550. return;
  551. }
  552. let obj = {};
  553. obj = this.pmList.find(function(item) {
  554. return item.id === key;
  555. });
  556. this.settingForm.pmName = obj.name;
  557. },
  558. selectSupplierName(key) {
  559. /* 处理供应商名称 */
  560. if (checkEmptyNumber(key)) {
  561. return;
  562. }
  563. let obj = {};
  564. obj = this.supplierList.find(function(item) {
  565. return item.id === key;
  566. });
  567. this.settingForm.supplierName = obj.name;
  568. },
  569. gotoProjectStatistic(row) {
  570. /* 查看项目统计 */
  571. let url = "/print/project/statistic/" + row.orgId + "/" + row.examId;
  572. this.$router.push({ path: url });
  573. },
  574. editProjectSetting() {
  575. /* 保存项目设置 */
  576. this.$refs.settingForm.validate(valid => {
  577. if (!valid) {
  578. return false;
  579. }
  580. this.selectPmName(this.settingForm.pmId);
  581. this.selectSupplierName(this.settingForm.supplierId);
  582. this.settingForm.prepareStartTime = formatGMT(this.prepareTimeRange[0]);
  583. this.settingForm.prepareEndTime = formatGMT(this.prepareTimeRange[1]);
  584. this.settingForm.printStartTime = formatGMT(this.printTimeRange[0]);
  585. this.settingForm.printEndTime = formatGMT(this.printTimeRange[1]);
  586. this.settingForm.mailStartTime = formatGMT(this.mailTimeRange[0]);
  587. this.settingForm.mailEndTime = formatGMT(this.mailTimeRange[1]);
  588. let curLoading = this.$loading({
  589. lock: true,
  590. text: "数据保存中!"
  591. });
  592. let url = PRINT_API + "/printing/project/update";
  593. this.$http.post(url, this.settingForm).then(
  594. () => {
  595. curLoading.close();
  596. this.$notify({
  597. title: "提示",
  598. type: "success",
  599. message: "项目设置成功!"
  600. });
  601. this.projectSettingDialog = false;
  602. this.searchRecords(1);
  603. },
  604. error => {
  605. console.log(error.response);
  606. curLoading.close();
  607. this.$notify({
  608. title: "错误",
  609. type: "error",
  610. message: error.response.data.desc
  611. });
  612. }
  613. );
  614. });
  615. },
  616. openProjectSettingDialog(row) {
  617. /* 打开项目设置弹窗 */
  618. this.projectSettingDialog = true;
  619. this.settingForm.id = row.id;
  620. this.settingForm.orgId = row.orgId;
  621. this.settingForm.examId = row.examId;
  622. this.settingForm.pmId = row.pmId;
  623. this.settingForm.pmName = row.pmName;
  624. this.settingForm.supplierId = row.supplierId;
  625. this.settingForm.supplierName = row.supplierName;
  626. this.prepareTimeRange = this.settingDateRange(
  627. row.prepareStartTime,
  628. row.prepareEndTime
  629. );
  630. this.printTimeRange = this.settingDateRange(
  631. row.printStartTime,
  632. row.printEndTime
  633. );
  634. this.mailTimeRange = this.settingDateRange(
  635. row.mailStartTime,
  636. row.mailEndTime
  637. );
  638. },
  639. closeProjectSettingDialog() {
  640. /* 关闭项目设置弹窗 */
  641. this.projectSettingDialog = false;
  642. },
  643. settingDateRange(startDate, endDate) {
  644. if (!checkEmptyStr(startDate) && !checkEmptyStr(endDate)) {
  645. return [startDate, endDate];
  646. }
  647. return [];
  648. }
  649. },
  650. computed: {
  651. ...mapState({ user: state => state.user })
  652. },
  653. created() {
  654. this.loadOrgList();
  655. this.loadUserRole(this.user);
  656. if (this.curUserRole.isSuperLeader) {
  657. this.hasPermit = true;
  658. this.loadPmList();
  659. this.loadSupplierList();
  660. } else if (this.curUserRole.isPM) {
  661. this.hasPermit = false;
  662. this.loadPmInfo(this.user);
  663. this.loadSupplierList();
  664. this.formSearch.pmId = this.user.userId;
  665. } else if (this.curUserRole.isSupplier) {
  666. this.hasPermit = false;
  667. this.loadPmList();
  668. this.loadSupplierInfo(this.user);
  669. this.formSearch.supplierId = this.user.userId;
  670. } else {
  671. this.hasPermit = false;
  672. }
  673. }
  674. };
  675. </script>
  676. <style scoped>
  677. .page {
  678. margin-top: 10px;
  679. }
  680. .pull-right {
  681. float: right;
  682. }
  683. .pull-left {
  684. float: left;
  685. }
  686. .w220 {
  687. width: 220px;
  688. }
  689. .w440 {
  690. width: 440px;
  691. }
  692. </style>