decomposePlan.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  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="form-box">
  34. <el-form :inline="true" class="demo-form-inline" :label-position="left" label-width="80px">
  35. <el-form-item label="选择路线">
  36. <el-input v-model="lineName" placeholder="必填" disabled > </el-input>
  37. </el-form-item>
  38. <el-form-item>
  39. <el-button type="primary" @click="drawerLine()">浏览</el-button>
  40. </el-form-item>
  41. </el-form>
  42. </div>
  43. <div class="box-form">
  44. <dil-form :formId="318" v-model="form"></dil-form>
  45. </div>
  46. <div class="capacityButton">
  47. <el-button type="primary" class="truckBtn" @click="drawerCapacity()">浏览车牌号</el-button>
  48. </div>
  49. <el-drawer
  50. :visible.sync="linedrawer"
  51. :direction="direction"
  52. :before-close="handleClose"
  53. size="40%"
  54. >
  55. <el-input placeholder="请输入内容" v-model="input" style="margin-top: 10px;margin-right: 10px;width:250px;" clearable> </el-input>
  56. <el-button type="primary" class="btn" @click="onclick()" style="margin-bottom:15px">
  57. <i class="el-icon-search"></i>查询
  58. </el-button>
  59. <dilTable v-bind.sync="zero" @radio-change="currentRadioChange1" ></dilTable>
  60. </el-drawer>
  61. <el-drawer
  62. :visible.sync="drawer"
  63. :direction="direction"
  64. :before-close="handleClose"
  65. size="30%"
  66. >
  67. <el-input placeholder="请输入内容" v-model="input" style="margin-top:10px;margin-right: 10px;width:150px;" clearable> </el-input>
  68. <el-button type="primary" class="btn" @click="onclick()" style="margin-bottom:15px">
  69. <i class="el-icon-search"></i>查询
  70. </el-button>
  71. <el-button type="primary" class="btn" @click="onConfirm()" style="margin-bottom:15px">
  72. <i class="el-icon-plus"></i>确认
  73. </el-button>
  74. <dilTable v-bind.sync="second" @selection-change="currentRadioChange" ></dilTable>
  75. </el-drawer>
  76. <vxe-table v-model="tableData" keep-source border resizable show-overflow show-footer ref="xTable"
  77. max-height="400" :footer-method="footerMethod" :data="tableData"
  78. :edit-config="{trigger: 'click', mode: 'cell', showStatus: true}"
  79. @edit-closed="editClosedEvent"
  80. @edit-actived="editActivedEvent">
  81. <vxe-table-column type="seq" width="60" title="序号"></vxe-table-column>
  82. <vxe-table-column field="planNo" title="运输计划号">
  83. <template #edit="{ row }">
  84. <vxe-input v-model="row.planNo" type="text" disabled></vxe-input>
  85. </template>
  86. </vxe-table-column>
  87. <vxe-table-column field="requirementNo" title="运输需求号"
  88. >
  89. <template #edit="{ row }">
  90. <vxe-input v-model="row.requirementNo" type="text" disabled></vxe-input>
  91. </template>
  92. </vxe-table-column>
  93. <!-- <vxe-table-column field="materialName" title="物资名称"
  94. >
  95. <template #edit="{ row }">
  96. <vxe-input v-model="row.materialName" type="text" disabled></vxe-input>
  97. </template>
  98. </vxe-table-column>
  99. <vxe-table-column field="materialWeight" title="物资重量" width="100"
  100. :edit-render="{}"
  101. >
  102. <template #edit="{ row }">
  103. <vxe-input v-model="row.materialWeight" type="text"></vxe-input>
  104. </template>
  105. </vxe-table-column>
  106. <vxe-table-column field="materialNumber" title="物资数量" width="100"
  107. :edit-render="{}"
  108. >
  109. <template #edit="{ row }">
  110. <vxe-input v-model="row.materialNumber" type="text" ></vxe-input>
  111. </template>
  112. </vxe-table-column> -->
  113. <vxe-table-column field="capacityNumber" title="车牌号"
  114. :edit-render="{}"
  115. >
  116. <template #edit="{ row }">
  117. <vxe-input v-model="row.capacityNumber" type="text" disabled></vxe-input>
  118. </template>
  119. </vxe-table-column>
  120. <vxe-column title="操作" width="200">
  121. <template #default="{ row }">
  122. <vxe-button status="danger" @click="removeRow(row)">删除</vxe-button>
  123. </template>
  124. </vxe-column>
  125. </vxe-table>
  126. <div class="button-box">
  127. <el-button type="primary" @click="makeSure">确认分解</el-button>
  128. <el-button type="primary" @click="cancel">返回</el-button>
  129. </div>
  130. </div>
  131. </template>
  132. <script>
  133. import { getCookie } from "@/utils/util.js";
  134. import PageTitle from "@/components/Page/Title";
  135. export default {
  136. components: {
  137. PageTitle,
  138. },
  139. data() {
  140. return {
  141. lineId:null,
  142. requirementId:null,
  143. capacityNumber:null,
  144. userCarrierId:null,
  145. lineName:null,
  146. linedrawer:false,
  147. tableData:[],
  148. direction: "rtl",
  149. input:'',
  150. selectRow:null,
  151. drawer:false,
  152. planNo:"",
  153. requirementNo:"",
  154. carrierId:null,
  155. form: {},
  156. first:{
  157. requestUrl: "/api/v1/ams/getTruckPlanList?apiId=258&planStatus=2&planId="+this.$route.params.planId,
  158. },
  159. second:{
  160. requestUrl:"/api/v1/uc/getAllCapacityByCarrierLike?apiId=429&carrierSsoId=" + null,
  161. selectionType: "select",
  162. mapList1:[]
  163. },
  164. zero:{
  165. requestUrl:"/api/v1/rms/getAllLineDesk?apiId=249",
  166. selectionType: "radio",
  167. mapList0:[]
  168. },
  169. oldRow: "",
  170. //记录上一个展开的点击次数,单数为展开状态,复数为闭合状态(未下发)
  171. oldRowCount: 1,
  172. tableHead: [
  173. {
  174. prop: "materialName",
  175. label: "物资名称",
  176. width: 150,
  177. },
  178. {
  179. prop:"loadName",
  180. label:"装货点",
  181. width:150
  182. },
  183. {
  184. prop:"unloadName",
  185. label:"卸货点",
  186. width:150
  187. },
  188. {
  189. prop:"loadSequence",
  190. label:"装卸货次序",
  191. width:150
  192. },
  193. {
  194. prop: "materialWeight",
  195. label: "物资重量",
  196. width: 150,
  197. },
  198. {
  199. prop: "materialCount",
  200. label: "物资数量",
  201. width: 150,
  202. },
  203. ],
  204. tableData1: [],
  205. };
  206. },
  207. created(){
  208. this.userCarrierId = getCookie("userId")
  209. this.second.requestUrl = "/api/v1/oms/getCapacityAndDriverList?apiId=246"
  210. },
  211. mounted(){
  212. this.information()
  213. },
  214. methods: {
  215. getRequirementMaterial(row) {
  216. // 记录重复点击次数
  217. if (this.oldRow === row) {
  218. this.oldRowCount += 1;
  219. }
  220. // 切换当前详情表
  221. this.$refs.table.toggleRowExpansion(row);
  222. // 打开前关闭上一个详情表
  223. if (this.oldRow != "") {
  224. if (this.oldRow != row) {
  225. if (this.oldRowCount % 2 === 1) {
  226. this.$refs.table.toggleRowExpansion(this.oldRow);
  227. } else {
  228. this.oldRowCount = 1;
  229. }
  230. } else {
  231. this.oldRow = null;
  232. return;
  233. }
  234. }
  235. // 重置上一个点击对象
  236. this.oldRow = row;
  237. this.getMaterial(row.requirementId);
  238. },
  239. getMaterial(requirementId){
  240. console.log(requirementId)
  241. this.axios.post("/api/v1/ams/getRequirementMaterial/" + requirementId).then((res) => {
  242. console.log(res.data.data);
  243. this.tableData1 = res.data.data
  244. })
  245. },
  246. drawerCapacity(){
  247. this.drawer = true;
  248. //重新初始化
  249. this.second.requestUrl = "/api/v1/uc/getAllCapacityByCarrierLike?apiId=429&carrierSsoId=" + null + "&i=" + new Date();
  250. },
  251. onConfirm(){
  252. console.log(this.mapList1)
  253. this.drawer = false
  254. this.mapList1.forEach((e) => {
  255. console.log((e.capacityNumber))
  256. this.capacityNumber = e.capacityNumber
  257. this.insertEvent()
  258. })
  259. },
  260. drawerLine(){
  261. this.linedrawer = true
  262. },
  263. onclick(){
  264. if(this.input != ''){
  265. this.second.requestUrl = "/api/v1/uc/getAllCapacityByCarrierLike?apiId=429&carrierSsoId="+this.input +"&carrierId=" + getCookie('userId');
  266. }else{
  267. this.second.requestUrl = "/api/v1/uc/getAllCapacityByCarrierLike?apiId=429&carrierSsoId=" + this.userCarrierId
  268. }
  269. },
  270. currentRadioChange(selection){
  271. this.mapList1=selection,
  272. console.log(this.mapList1)
  273. },
  274. currentRadioChange1(selection){
  275. this.mapList0=selection
  276. this.lineName = this.mapList0.lineName
  277. this.lineId = this.mapList0.lineId
  278. console.log(this.mapList0.lineId)
  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=2&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. if(typeof(this.form.orderType) == 'undefined'){
  329. this.$alert('没有选择订单类型,请选择')
  330. return
  331. }
  332. for(var i=0;i<this.$refs.xTable.getInsertRecords().length;i++){
  333. if(this.$refs.xTable.getInsertRecords()[i].capacityNumber == null){
  334. this.$alert('未选择车牌,请选择车牌')
  335. return
  336. }
  337. }
  338. let BmsTrainFreight = {
  339. planId:this.$route.params.planId,
  340. lineId:this.lineId,
  341. orderType:this.form.orderType,
  342. carrierId:this.carrierId,
  343. mapList:this.$refs.xTable.getInsertRecords()
  344. };
  345. console.log(BmsTrainFreight)
  346. debugger
  347. this.axios
  348. .post("/api/v1/oms/addInwardOrder", BmsTrainFreight)
  349. .then((res) => {
  350. if (res.data.code == 200) {
  351. this.$router.go(-1);
  352. this.$message({
  353. type: "success",
  354. message: "分解成功!",
  355. });
  356. } else {
  357. this.$message.error("分解失败!");
  358. }
  359. });
  360. },
  361. // 返回
  362. cancel() {
  363. console.log(this.sumNum(this.$refs.xTable.getInsertRecords(), 'materialWeight'))
  364. },
  365. },
  366. };
  367. </script>
  368. <style lang="scss" scoped>
  369. .desomposePlan{
  370. .form-box{
  371. display: inline-block !important;
  372. margin-left: 38%;
  373. .el-input{
  374. width:288px
  375. }
  376. .el-form{
  377. padding: 10px;
  378. }
  379. }
  380. .box-form{
  381. // display: flex;
  382. // justify-content: center;
  383. padding-left: 40.5%;
  384. margin-right: 100px;
  385. .el-form-item__content {
  386. display: flex;
  387. }
  388. }
  389. .capacityButton {
  390. // width: 800px;
  391. display: flex;
  392. justify-content: center;
  393. align-items: center;
  394. margin-left: 150px;
  395. .truckBtn {
  396. width: 300px;
  397. }
  398. }
  399. .button-box{
  400. display: flex;
  401. justify-content: center;
  402. margin-left: 25px !important;
  403. }
  404. }
  405. </style>