decomposePlan.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. // 分解计划
  2. <template>
  3. <div class="desomposePlan">
  4. <page-title>分解计划</page-title>
  5. <dilTable v-bind.sync="first" ref="table">
  6. <el-table-column fixed="right" label="操作" width="100">
  7. <template slot-scope="scope">
  8. <el-button type="text" size="mini" @click="getRequirementMaterial(scope.row)">
  9. 物资详情
  10. </el-button>
  11. </template>
  12. </el-table-column>
  13. <!-- 物资详情抽屉 -->
  14. <el-table-column type="expand" width="1">
  15. <template slot-scope="props">
  16. <el-form label-position="center" inline class="demo-table-expand">
  17. <div v-if="false">{{ props }}</div>
  18. <div>
  19. <el-table :data="tableData1" border >
  20. <el-table-column
  21. v-for="(item, i) in tableHead"
  22. :key="i"
  23. :prop="item.prop"
  24. :label="item.label"
  25. :width="item.width"
  26. ></el-table-column>
  27. </el-table>
  28. </div>
  29. </el-form>
  30. </template>
  31. </el-table-column>
  32. </dilTable>
  33. <div class="capacityButton">
  34. <el-button type="primary" class="truckBtn" @click="drawerCapacity()">浏览车牌号</el-button>
  35. </div>
  36. <el-drawer
  37. :visible.sync="drawer"
  38. :with-header="false"
  39. :destroy-on-close="true"
  40. direction="rtl"
  41. size="40%"
  42. :show-close="true"
  43. :wrapperClosable="false"
  44. close-on-press-escape
  45. >
  46. <el-input
  47. placeholder="请输入内容"
  48. v-model="truckText"
  49. style="margin-top: 10px; margin-left: 20px; width: 250px"
  50. clearable
  51. >
  52. </el-input>
  53. <el-button
  54. type="primary"
  55. class="btn"
  56. @click="onclick"
  57. style="margin-left: 5px"
  58. >
  59. <i class="el-icon-search"></i>查询
  60. </el-button>
  61. <el-button
  62. type="primary"
  63. class="btn"
  64. @click="onConfirm"
  65. style="margin-left: 5px"
  66. >
  67. <i class="el-icon-check"></i>确定
  68. </el-button>
  69. <div class="tablecls">
  70. <!-- 查询所有的车辆 -->
  71. <dilTable
  72. v-bind.sync="second"
  73. :isHeigth="isHeigth" :shiyHeigth="shiyHeigth" :isKuang="isKuang"
  74. @selection-change="currentRadioChange"
  75. ></dilTable>
  76. </div>
  77. </el-drawer>
  78. <vxe-table v-model="tableData" keep-source border resizable show-overflow show-footer ref="xTable"
  79. max-height="400" :footer-method="footerMethod" :data="tableData"
  80. :edit-config="{trigger: 'click', mode: 'cell', showStatus: true}"
  81. @edit-closed="editClosedEvent"
  82. @edit-actived="editActivedEvent">
  83. <vxe-table-column type="seq" width="60" title="序号"></vxe-table-column>
  84. <vxe-table-column field="planNo" title="运输计划号">
  85. <template #edit="{ row }">
  86. <vxe-input v-model="row.planNo" type="text" disabled></vxe-input>
  87. </template>
  88. </vxe-table-column>
  89. <vxe-table-column field="requirementNo" title="运输需求号"
  90. >
  91. <template #edit="{ row }">
  92. <vxe-input v-model="row.requirementNo" type="text" disabled></vxe-input>
  93. </template>
  94. </vxe-table-column>
  95. <vxe-table-column field="capacityNumber" title="车牌号"
  96. :edit-render="{}"
  97. >
  98. <template #edit="{ row }">
  99. <vxe-input v-model="row.capacityNumber" type="text" disabled></vxe-input>
  100. </template>
  101. </vxe-table-column>
  102. <vxe-column title="操作" width="200">
  103. <template #default="{ row }">
  104. <vxe-button status="danger" @click="removeRow(row)">删除</vxe-button>
  105. </template>
  106. </vxe-column>
  107. </vxe-table>
  108. <div class="button-box">
  109. <el-button type="primary" @click="makeSure" :disabled = "disabled">确认分解</el-button>
  110. <el-button type="primary" @click="cancel">返回</el-button>
  111. </div>
  112. </div>
  113. </template>
  114. <script>
  115. import { getCookie } from "@/utils/util.js";
  116. import PageTitle from "@/components/Page/Title";
  117. export default {
  118. components: {
  119. PageTitle,
  120. },
  121. data() {
  122. return {
  123. disabled:false,
  124. truckText:null,
  125. shiyHeigth:140,
  126. isHeigth:true,
  127. isKuang:false,
  128. requirementId:null,
  129. capacityNumber:null,
  130. userCarrierId:null,
  131. lineName:null,
  132. linedrawer:false,
  133. tableData:[],
  134. direction: "rtl",
  135. input:null,
  136. selectRow:null,
  137. drawer:false,
  138. planNo:"",
  139. requirementNo:"",
  140. carrierId:null,
  141. form: {},
  142. first:{
  143. requestUrl: "/api/v1/ams/getTruckPlanList?apiId=258&planStatus=100&planId="+this.$route.params.planId,
  144. },
  145. second:{
  146. requestUrl:"/api/v1/uc/getAllCapacityByCarrierLike?apiId=429&carrierSsoId=" + null,
  147. selectionType: "select",
  148. mapList1:[]
  149. },
  150. oldRow: "",
  151. //记录上一个展开的点击次数,单数为展开状态,复数为闭合状态(未下发)
  152. oldRowCount: 1,
  153. tableHead: [
  154. {
  155. prop: "materialName",
  156. label: "物资名称",
  157. width: 150,
  158. },
  159. {
  160. prop:"loadName",
  161. label:"装货点",
  162. width:150
  163. },
  164. {
  165. prop:"unloadName",
  166. label:"卸货点",
  167. width:150
  168. },
  169. {
  170. prop:"loadSequence",
  171. label:"装卸货次序",
  172. width:150
  173. },
  174. {
  175. prop: "materialWeight",
  176. label: "物资重量",
  177. width: 150,
  178. },
  179. {
  180. prop: "materialCount",
  181. label: "物资数量",
  182. width: 150,
  183. },
  184. ],
  185. tableData1: [],
  186. newsArr:[]
  187. };
  188. },
  189. created(){
  190. if (getCookie("orgCode") == "chengyunshang") {
  191. this.second.requestUrl =
  192. "/api/v1/uc/getAllCapacityByCarrierLike?apiId=248&carrierSsoId=" +
  193. getCookie("userId");
  194. } else if(getCookie("orgCode") == "wuliuchuyunzhongxin"){
  195. this.second.requestUrl =
  196. "/api/v1/uc/getAllCapacityByCarrierLike?apiId=429&carrierSsoId=" + null + "&indexText="+"物流储运中心";
  197. }else {
  198. this.second.requestUrl =
  199. "/api/v1/uc/getAllCapacityByCarrierLike?apiId=429&carrierSsoId=" + null
  200. }
  201. },
  202. mounted(){
  203. this.information()
  204. },
  205. methods: {
  206. getInwardRequestUrl(){
  207. if (getCookie("orgCode") == "chengyunshang") {
  208. this.second.requestUrl =
  209. "/api/v1/uc/getAllCapacityByCarrierLike?apiId=429&carrierSsoId=" +
  210. getCookie("userId") + "&i=" + new Date();
  211. } else if(getCookie("orgCode") == "wuliuchuyunzhongxin"){
  212. this.second.requestUrl =
  213. "/api/v1/uc/getAllCapacityByCarrierLike?apiId=429&carrierSsoId=" + null + "&indexText="+"物流储运中心" + "&i=" + new Date();
  214. }else {
  215. this.second.requestUrl =
  216. "/api/v1/uc/getAllCapacityByCarrierLike?apiId=429&carrierSsoId=" + null + "&i=" + new Date();
  217. }
  218. },
  219. getRequirementMaterial(row) {
  220. // 记录重复点击次数
  221. if (this.oldRow === row) {
  222. this.oldRowCount += 1;
  223. }
  224. // 切换当前详情表
  225. this.$refs.table.toggleRowExpansion(row);
  226. // 打开前关闭上一个详情表
  227. if (this.oldRow != "") {
  228. if (this.oldRow != row) {
  229. if (this.oldRowCount % 2 === 1) {
  230. this.$refs.table.toggleRowExpansion(this.oldRow);
  231. } else {
  232. this.oldRowCount = 1;
  233. }
  234. } else {
  235. this.oldRow = null;
  236. return;
  237. }
  238. }
  239. // 重置上一个点击对象
  240. this.oldRow = row;
  241. this.getMaterial(row.requirementId);
  242. },
  243. getMaterial(requirementId){
  244. console.log(requirementId)
  245. this.axios.post("/api/v1/ams/getRequirementMaterial/" + requirementId).then((res) => {
  246. console.log(res.data.data);
  247. this.tableData1 = res.data.data
  248. })
  249. },
  250. drawerCapacity(){
  251. this.getInwardRequestUrl()
  252. this.drawer = true;
  253. //重新初始化
  254. },
  255. onConfirm(){
  256. console.log(this.mapList1)
  257. this.drawer = false
  258. this.newsArr.forEach((e) => {
  259. console.log((e.capacityNumber))
  260. this.capacityNumber = e.capacityNumber
  261. this.insertEvent()
  262. })
  263. this.newsArr = []
  264. },
  265. onclick(){
  266. if(this.truckText != null){
  267. this.second.requestUrl = "/api/v1/uc/getAllCapacityByCarrierLike?apiId=429&carrierSsoId="+this.input +"&carrierId=" + getCookie('userId') + "&index=" + this.truckText;
  268. }else{
  269. this.second.requestUrl = "/api/v1/uc/getAllCapacityByCarrierLike?apiId=429&carrierSsoId=" + this.userCarrierId + "&i=" + new Date()
  270. }
  271. },
  272. currentRadioChange(selection){
  273. this.mapList1=selection
  274. for (let i = 0; i < selection.length; i++) {
  275. if(this.newsArr.indexOf(selection[i]) === -1){
  276. this.newsArr.push(selection[i]);
  277. }
  278. }
  279. },
  280. handleClose(done){
  281. done();
  282. },
  283. sumNum (list, field) {
  284. let count = 0
  285. list.forEach(item => {
  286. count += Number(item[field])
  287. })
  288. return count
  289. },
  290. information() {
  291. //查看需求详情
  292. this.axios
  293. .post(
  294. "/api/v1/ams/getTruckPlanList?apiId=258&planStatus=200&planId=" + this.$route.params.planId
  295. )
  296. .then((res) => {
  297. console.log(res.data.data)
  298. var planRow = res.data.data.list
  299. this.requirementNo = planRow[0].requirementNumber,
  300. this.planNo = planRow[0].planNumber,
  301. this.carrierId = planRow[0].carrierId,
  302. this.requirementId = planRow[0].requirementId
  303. console.log(this.requirementId)
  304. this.axios.post("/api/v1/ams/getRequirementMaterial/" + this.requirementId).then((res) => {
  305. console.log(res.data.data);
  306. this.tableData1 = res.data.data
  307. })
  308. });
  309. },
  310. async insertEvent (row,) {
  311. const $table = this.$refs.xTable
  312. const record = {
  313. requirementNo:this.requirementNo,
  314. planNo:this.planNo,
  315. capacityNumber:this.capacityNumber,
  316. orderMaterialList:this.tableData1,
  317. }
  318. const { row: newRow } = await $table.insertAt(record, row)
  319. await $table.setActiveCell(newRow, 'name')
  320. },
  321. //删除行
  322. async removeRow (row) {
  323. const $table = this.$refs.xTable
  324. await $table.remove(row)
  325. },
  326. // 修改
  327. makeSure() {
  328. this.disabled = true
  329. for(var i=0;i<this.$refs.xTable.getInsertRecords().length;i++){
  330. if(this.$refs.xTable.getInsertRecords()[i].capacityNumber == null){
  331. this.$alert('未选择车牌,请选择车牌')
  332. this.disabled = false
  333. return
  334. }
  335. }
  336. let BmsTrainFreight = {
  337. planId:Number(this.$route.params.planId),
  338. orderType:11,
  339. carrierId:this.carrierId,
  340. userId:getCookie("userId"),
  341. mapList:this.$refs.xTable.getInsertRecords()
  342. };
  343. this.axios
  344. .post("/api/v1/oms/addInwardOrder", BmsTrainFreight)
  345. .then((res) => {
  346. if (res.data.code == 200) {
  347. this.$message({
  348. type: "success",
  349. message: "分解成功!",
  350. });
  351. this.cancel()
  352. this.disabled = false
  353. } else {
  354. this.$message.error("分解失败!");
  355. this.disabled = false
  356. }
  357. });
  358. },
  359. // 返回
  360. cancel() {
  361. this.$router.go(-1);
  362. },
  363. },
  364. };
  365. </script>
  366. <style lang="scss" scoped>
  367. .desomposePlan{
  368. .form-box{
  369. display: inline-block !important;
  370. margin-left: 38%;
  371. .el-input{
  372. width:288px
  373. }
  374. .el-form{
  375. padding: 10px;
  376. }
  377. }
  378. .box-form{
  379. // display: flex;
  380. // justify-content: center;
  381. padding-left: 40.5%;
  382. margin-right: 100px;
  383. .el-form-item__content {
  384. display: flex;
  385. }
  386. }
  387. .capacityButton {
  388. display: flex;
  389. justify-content: center;
  390. align-items: center;
  391. margin-top: 20px;
  392. .truckBtn {
  393. width: 300px;
  394. }
  395. }
  396. .button-box{
  397. display: flex;
  398. justify-content: center;
  399. margin-left: 25px !important;
  400. }
  401. }
  402. </style>