plan.vue 14 KB

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