plan.vue 15 KB

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