plan.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. // 制定计划
  2. <template>
  3. <div class="inwardPlan">
  4. <div class="sache">
  5. <el-input placeholder="请输入内容" v-model="inputText" clearable>
  6. </el-input>
  7. <el-button type="primary" class="btn">
  8. <i class="el-icon-search"></i>查询
  9. </el-button>
  10. <el-badge
  11. :value="addPlanCount"
  12. class="item"
  13. v-if="activeName == 'second'"
  14. >
  15. <el-button
  16. type="primary"
  17. class="btn"
  18. @click="toInsert"
  19. v-if="activeName == 'second'"
  20. >
  21. <i class="el-icon-plus"></i>制定计划
  22. </el-button>
  23. </el-badge>
  24. <!-- <audio
  25. id="audioId"
  26. controls="controls"
  27. preload="auto"
  28. loop = "isloop"
  29. src="/static/music/y682.mp3">
  30. </audio> -->
  31. <el-button
  32. type="primary"
  33. class="btn"
  34. @click="Issue"
  35. v-if="activeName == 'second'"
  36. >
  37. <i class="el-icon-download"></i>下发
  38. </el-button>
  39. </div>
  40. <template>
  41. <div>
  42. <el-tabs v-model="activeName" @tab-click="handleClick">
  43. <el-tab-pane label="未下发" name="second">
  44. <dilTable
  45. v-bind.sync="second"
  46. @selection-change="selectionChange"
  47. ref="table1"
  48. >
  49. <el-table-column fixed="right" label="操作" width="180">
  50. <template slot-scope="scope">
  51. <el-button
  52. type="text"
  53. size="mini"
  54. @click="getRequirementMaterial1(scope.row)"
  55. >
  56. 物资详情
  57. </el-button>
  58. <el-button type="text" size="mini" @click="updatePlan(scope)">
  59. 修改
  60. </el-button>
  61. <el-button type="text" size="mini" @click="deletePlan(scope)">
  62. 删除
  63. </el-button>
  64. </template>
  65. </el-table-column>
  66. <!-- 物资详情抽屉 -->
  67. <el-table-column type="expand" width="1">
  68. <template slot-scope="props">
  69. <el-form
  70. label-position="center"
  71. inline
  72. class="demo-table-expand"
  73. >
  74. <div v-if="false">{{ props }}</div>
  75. <div>
  76. <el-table :data="tableData" border>
  77. <el-table-column
  78. v-for="(item, i) in tableHead"
  79. :key="i"
  80. :prop="item.prop"
  81. :label="item.label"
  82. :width="item.width"
  83. ></el-table-column>
  84. </el-table>
  85. </div>
  86. </el-form>
  87. </template>
  88. </el-table-column>
  89. </dilTable>
  90. </el-tab-pane>
  91. <el-tab-pane label="已下发" name="third">
  92. <mergeRowTable v-bind.sync="third" ref="table2">
  93. <el-table-column
  94. fixed="right"
  95. align="center"
  96. label="操作"
  97. width="180"
  98. >
  99. <template slot-scope="scope">
  100. <el-button
  101. type="text"
  102. size="mini"
  103. @click="getRequirementMaterial2(scope.row)"
  104. >
  105. 物资详情
  106. </el-button>
  107. <el-button type="text" size="mini" @click="finishPlan(scope)">
  108. 确认完成
  109. </el-button>
  110. </template>
  111. </el-table-column>
  112. <!-- 物资详情抽屉 -->
  113. <el-table-column type="expand" width="1">
  114. <template slot-scope="props">
  115. <el-form
  116. label-position="center"
  117. inline
  118. class="demo-table-expand"
  119. >
  120. <div v-if="false">{{ props }}</div>
  121. <div>
  122. <el-table :data="tableData" border>
  123. <el-table-column
  124. v-for="(item, i) in tableHead"
  125. :key="i"
  126. :prop="item.prop"
  127. :label="item.label"
  128. :width="item.width"
  129. ></el-table-column>
  130. </el-table>
  131. </div>
  132. </el-form>
  133. </template>
  134. </el-table-column>
  135. </mergeRowTable>
  136. </el-tab-pane>
  137. <!-- <el-tab-pane label="已完成" name="fourth">
  138. <dilTable
  139. v-bind.sync="fourth"
  140. @selection-change="selectionChange"
  141. ref="table3"
  142. >
  143. <el-table-column
  144. fixed="right"
  145. align="center"
  146. label="操作"
  147. width="100"
  148. >
  149. <template slot-scope="scope">
  150. <el-button
  151. type="text"
  152. size="mini"
  153. @click="getRequirementMaterial3(scope.row)"
  154. >
  155. 物资详情
  156. </el-button>
  157. </template>
  158. </el-table-column>
  159. <el-table-column type="expand" width="1">
  160. <template slot-scope="props">
  161. <el-form
  162. label-position="center"
  163. inline
  164. class="demo-table-expand"
  165. >
  166. <div v-if="false">{{ props }}</div>
  167. <div>
  168. <el-table :data="tableData" border>
  169. <el-table-column
  170. v-for="(item, i) in tableHead"
  171. :key="i"
  172. :prop="item.prop"
  173. :label="item.label"
  174. :width="item.width"
  175. ></el-table-column>
  176. </el-table>
  177. </div>
  178. </el-form>
  179. </template>
  180. </el-table-column>
  181. </dilTable>
  182. </el-tab-pane> -->
  183. </el-tabs>
  184. </div>
  185. </template>
  186. </div>
  187. </template>
  188. <script>
  189. export default {
  190. data() {
  191. return {
  192. inputText: "",
  193. first: {
  194. // first请求数据的地址
  195. requestUrl: ""
  196. },
  197. second: {
  198. // second请求数据的地址
  199. requestUrl: "",
  200. selectionType: "select",
  201. mapList: []
  202. },
  203. third: {
  204. columnIndexs:[0,1,2,3,4,5,9,10,13,16,21,22],
  205. comparison: "requirementNumber",
  206. // second请求数据的地址
  207. requestUrl: ""
  208. },
  209. // fourth: {
  210. // requestUrl: ""
  211. // },
  212. activeName: "second",
  213. //记录旧的row对象(未下发)
  214. oldRow: "",
  215. //记录上一个展开的点击次数,单数为展开状态,复数为闭合状态(未下发)
  216. oldRowCount: 1,
  217. //记录旧的row对象(已下发)
  218. oldRow1: "",
  219. //记录上一个展开的点击次数,单数为展开状态,复数为闭合状态(已下发)
  220. oldRowCount1: 1,
  221. oldRow2: "",
  222. //记录上一个展开的点击次数,单数为展开状态,复数为闭合状态(未下发)
  223. oldRowCount2: 1,
  224. oldRow3: "",
  225. //记录上一个展开的点击次数,单数为展开状态,复数为闭合状态(未下发)
  226. oldRowCount3: 1,
  227. tableHead: [
  228. {
  229. prop: "materialName",
  230. label: "物资名称",
  231. width: 150
  232. },
  233. {
  234. prop: "loadName",
  235. label: "装货点",
  236. width: 150
  237. },
  238. {
  239. prop: "unloadName",
  240. label: "卸货点",
  241. width: 150
  242. },
  243. {
  244. prop: "loadSequence",
  245. label: "装卸货次序",
  246. width: 150
  247. },
  248. {
  249. prop: "materialWeight",
  250. label: "物资重量",
  251. width: 150
  252. },
  253. {
  254. prop: "materialCount",
  255. label: "物资数量",
  256. width: 150
  257. }
  258. ],
  259. tableData: [],
  260. addPlanCount: 0,
  261. timer: ""
  262. };
  263. },
  264. created() {
  265. this.second.requestUrl =
  266. "/api/v1/ams/getTruckPlanList?apiId=257&planStatus=0";
  267. this.third.requestUrl =
  268. "/api/v1/ams/getTruckPlanList?apiId=258&planStatus=1";
  269. // this.fourth.requestUrl =
  270. // "/api/v1/ams/getTruckPlanList?apiId=258&planStatus=4";
  271. },
  272. mounted() {
  273. this.getAddPlan();
  274. this.start();
  275. },
  276. beforeDestroy() {
  277. this.timer;
  278. },
  279. methods: {
  280. getAddPlan() {
  281. this.axios.post("/api/v1/uc/getPlanCount").then(res => {
  282. this.addPlanCount = res.data;
  283. });
  284. },
  285. start() {
  286. this.timer = setInterval(this.getAddPlan, 60000);
  287. },
  288. getRequirementMaterial(row) {
  289. // 记录重复点击次数
  290. if (this.oldRow === row) {
  291. this.oldRowCount += 1;
  292. }
  293. // 切换当前详情表
  294. this.$refs.table.toggleRowExpansion(row);
  295. // 打开前关闭上一个详情表
  296. if (this.oldRow != "") {
  297. if (this.oldRow != row) {
  298. if (this.oldRowCount % 2 === 1) {
  299. this.$refs.table.toggleRowExpansion(this.oldRow);
  300. } else {
  301. this.oldRowCount = 1;
  302. }
  303. } else {
  304. this.oldRow = null;
  305. return;
  306. }
  307. }
  308. // 重置上一个点击对象
  309. this.oldRow = row;
  310. this.getMaterial(row.requirementId);
  311. },
  312. getRequirementMaterial1(row) {
  313. // 记录重复点击次数
  314. if (this.oldRow1 === row) {
  315. this.oldRowCount1 += 1;
  316. }
  317. // 切换当前详情表
  318. this.$refs.table1.toggleRowExpansion(row);
  319. // 打开前关闭上一个详情表
  320. if (this.oldRow1 != "") {
  321. if (this.oldRow1 != row) {
  322. if (this.oldRowCount1 % 2 === 1) {
  323. this.$refs.table1.toggleRowExpansion(this.oldRow1);
  324. } else {
  325. this.oldRowCount1 = 1;
  326. }
  327. } else {
  328. this.oldRow1 = null;
  329. return;
  330. }
  331. }
  332. // 重置上一个点击对象
  333. this.oldRow1 = row;
  334. this.getMaterial(row.requirementId);
  335. },
  336. getRequirementMaterial2(row) {
  337. // 记录重复点击次数
  338. if (this.oldRow2 === row) {
  339. this.oldRowCount2 += 1;
  340. }
  341. // 切换当前详情表
  342. this.$refs.table2.toggleRowExpansion(row);
  343. // 打开前关闭上一个详情表
  344. if (this.oldRow2 != "") {
  345. if (this.oldRow2 != row) {
  346. if (this.oldRowCount2 % 2 === 1) {
  347. this.$refs.table2.toggleRowExpansion(this.oldRow2);
  348. } else {
  349. this.oldRowCount2 = 1;
  350. }
  351. } else {
  352. this.oldRow2 = null;
  353. return;
  354. }
  355. }
  356. // 重置上一个点击对象
  357. this.oldRow2 = row;
  358. this.getMaterial(row.requirementId);
  359. },
  360. getRequirementMaterial3(row) {
  361. // 记录重复点击次数
  362. if (this.oldRow3 === row) {
  363. this.oldRowCount3 += 1;
  364. }
  365. // 切换当前详情表
  366. this.$refs.table3.toggleRowExpansion(row);
  367. // 打开前关闭上一个详情表
  368. if (this.oldRow3 != "") {
  369. if (this.oldRow3 != row) {
  370. if (this.oldRowCount3 % 2 === 1) {
  371. this.$refs.table3.toggleRowExpansion(this.oldRow2);
  372. } else {
  373. this.oldRowCount3 = 1;
  374. }
  375. } else {
  376. this.oldRow3 = null;
  377. return;
  378. }
  379. }
  380. // 重置上一个点击对象
  381. this.oldRow3 = row;
  382. this.getMaterial(row.requirementId);
  383. },
  384. getMaterial(requirementId) {
  385. console.log(requirementId);
  386. this.axios
  387. .post("/api/v1/ams/getRequirementMaterial/" + requirementId)
  388. .then(res => {
  389. this.tableData = res.data.data;
  390. console.log(res.data.data);
  391. });
  392. },
  393. handleClick(tab, event) {
  394. this.getRequestUrl();
  395. this.getRequirementMaterial();
  396. },
  397. getRequestUrl() {
  398. // this.first.requestUrl =
  399. // "/api/v1/ams/getTruckRequirementList?apiId=207&requirementStatus=1&i=" +
  400. // new Date();
  401. this.second.requestUrl =
  402. "/api/v1/ams/getTruckPlanList?apiId=257&planStatus=0" +
  403. "&i=" +
  404. new Date();
  405. this.third.requestUrl =
  406. "/api/v1/ams/getTruckPlanList?apiId=258&planStatus=1" +
  407. "&i=" +
  408. new Date();
  409. // (this.fourth.requestUrl =
  410. // "/api/v1/ams/getTruckPlanList?apiId=258&planStatus=4" +
  411. // "&i=" +
  412. // new Date());
  413. },
  414. selectionChange(selection) {
  415. this.second.mapList = selection;
  416. },
  417. toInsert() {
  418. console.log("---");
  419. this.$router.push("/addPlan");
  420. },
  421. updatePlan(scope) {
  422. this.$router.push("/updatePlan/" + scope.row.planId);
  423. },
  424. finishPlan(scope) {
  425. this.$confirm("是否完成该计划", "提示", {
  426. confirmButtonText: "确定",
  427. cancelButtonText: "取消",
  428. type: "warning",
  429. center: true
  430. })
  431. .then(() => {
  432. this.axios
  433. .post("/api/v1/ams/finishTruckPlan/" + scope.row.planId)
  434. .then(res => {
  435. if (res.data.code == "200") {
  436. this.$message({
  437. type: "success",
  438. message: "已完成该计划!"
  439. });
  440. this.getRequestUrl();
  441. } else {
  442. this.$message({
  443. message: "操作失败",
  444. type: "warning"
  445. });
  446. }
  447. });
  448. })
  449. .catch(() => {
  450. this.$message({
  451. type: "info",
  452. message: "操作已取消!"
  453. });
  454. });
  455. },
  456. deletePlan(scope) {
  457. this.$confirm("是否删除", "提示", {
  458. confirmButtonText: "确定",
  459. cancelButtonText: "取消",
  460. type: "warning",
  461. center: true
  462. })
  463. .then(() => {
  464. this.axios
  465. .post("/api/v1/ams/deleteTruckPlan/" + scope.row.planId)
  466. .then(res => {
  467. if (res.data.code == 200) {
  468. this.$message({
  469. type: "success",
  470. message: "删除成功!"
  471. });
  472. this.getRequestUrl();
  473. this.getAddPlan();
  474. } else {
  475. this.$message({
  476. message: "删除失败",
  477. type: "warning"
  478. });
  479. }
  480. });
  481. })
  482. .catch(() => {
  483. this.$message({
  484. type: "info",
  485. message: "删除操作已取消!"
  486. });
  487. });
  488. },
  489. Issue() {
  490. if (this.second.mapList.length == 0) {
  491. this.$message.error("选择计划后才能下发");
  492. return;
  493. }
  494. console.log(this.second.mapList);
  495. this.$confirm("是否下发", "提示", {
  496. confirmButtonText: "确定",
  497. cancelButtonText: "取消",
  498. type: "warning",
  499. center: true
  500. })
  501. .then(() => {
  502. this.axios
  503. .post("/api/v1/ams/downTruckPlan", this.second.mapList)
  504. .then(res => {
  505. if (res.data.code == 200) {
  506. this.$message({
  507. type: "success",
  508. message: "下发成功!"
  509. });
  510. this.getRequestUrl();
  511. this.getAddPlan();
  512. this.activeName = "third";
  513. } else {
  514. this.$message({
  515. message: "下发失败",
  516. type: "warning"
  517. });
  518. }
  519. });
  520. })
  521. .catch(() => {
  522. this.$message({
  523. type: "info",
  524. message: "取消下发!"
  525. });
  526. });
  527. }
  528. }
  529. };
  530. </script>
  531. <style lang="scss">
  532. .inwardPlan {
  533. margin-top: 20px;
  534. margin-left: 20px;
  535. .sache {
  536. padding: 1.25rem 0.375rem;
  537. .el-input {
  538. width: 20%;
  539. margin-right: 1.25rem;
  540. }
  541. }
  542. }
  543. </style>