decomposePlan.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  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">确认分解</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. truckText:null,
  124. shiyHeigth:140,
  125. isHeigth:true,
  126. isKuang:false,
  127. lineId:null,
  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=2&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. };
  187. },
  188. created(){
  189. this.userCarrierId = getCookie("userId")
  190. this.second.requestUrl = "/api/v1/oms/getCapacityAndDriverList?apiId=246"
  191. },
  192. mounted(){
  193. this.information()
  194. },
  195. methods: {
  196. getRequirementMaterial(row) {
  197. // 记录重复点击次数
  198. if (this.oldRow === row) {
  199. this.oldRowCount += 1;
  200. }
  201. // 切换当前详情表
  202. this.$refs.table.toggleRowExpansion(row);
  203. // 打开前关闭上一个详情表
  204. if (this.oldRow != "") {
  205. if (this.oldRow != row) {
  206. if (this.oldRowCount % 2 === 1) {
  207. this.$refs.table.toggleRowExpansion(this.oldRow);
  208. } else {
  209. this.oldRowCount = 1;
  210. }
  211. } else {
  212. this.oldRow = null;
  213. return;
  214. }
  215. }
  216. // 重置上一个点击对象
  217. this.oldRow = row;
  218. this.getMaterial(row.requirementId);
  219. },
  220. getMaterial(requirementId){
  221. console.log(requirementId)
  222. this.axios.post("/api/v1/ams/getRequirementMaterial/" + requirementId).then((res) => {
  223. console.log(res.data.data);
  224. this.tableData1 = res.data.data
  225. })
  226. },
  227. drawerCapacity(){
  228. this.drawer = true;
  229. //重新初始化
  230. this.second.requestUrl = "/api/v1/uc/getAllCapacityByCarrierLike?apiId=429&carrierSsoId=" + null + "&i=" + new Date();
  231. },
  232. onConfirm(){
  233. console.log(this.mapList1)
  234. this.drawer = false
  235. this.mapList1.forEach((e) => {
  236. console.log((e.capacityNumber))
  237. this.capacityNumber = e.capacityNumber
  238. this.insertEvent()
  239. })
  240. },
  241. drawerLine(){
  242. this.linedrawer = true
  243. },
  244. onclick(){
  245. console.log(this.truckText,"truckText")
  246. if(this.truckText != null){
  247. this.second.requestUrl = "/api/v1/uc/getAllCapacityByCarrierLike?apiId=429&carrierSsoId="+this.input +"&carrierId=" + getCookie('userId') + "&index=" + this.truckText;
  248. }else{
  249. this.second.requestUrl = "/api/v1/uc/getAllCapacityByCarrierLike?apiId=429&carrierSsoId=" + this.userCarrierId + "&i=" + new Date()
  250. }
  251. },
  252. currentRadioChange(selection){
  253. this.mapList1=selection,
  254. console.log(this.mapList1)
  255. },
  256. currentRadioChange1(selection){
  257. this.mapList0=selection
  258. this.lineName = this.mapList0.lineName
  259. this.lineId = this.mapList0.lineId
  260. console.log(this.mapList0.lineId)
  261. },
  262. handleClose(done){
  263. done();
  264. },
  265. sumNum (list, field) {
  266. let count = 0
  267. list.forEach(item => {
  268. count += Number(item[field])
  269. })
  270. return count
  271. },
  272. information() {
  273. //查看需求详情
  274. this.axios
  275. .post(
  276. "/api/v1/ams/getTruckPlanList?apiId=258&planStatus=2&planId=" + this.$route.params.planId
  277. )
  278. .then((res) => {
  279. console.log(res.data.data)
  280. var planRow = res.data.data.list
  281. this.requirementNo = planRow[0].requirementNumber,
  282. this.planNo = planRow[0].planNumber,
  283. this.carrierId = planRow[0].carrierId,
  284. this.requirementId = planRow[0].requirementId
  285. console.log(this.requirementId)
  286. this.axios.post("/api/v1/ams/getRequirementMaterial/" + this.requirementId).then((res) => {
  287. console.log(res.data.data);
  288. this.tableData1 = res.data.data
  289. })
  290. });
  291. },
  292. async insertEvent (row,) {
  293. const $table = this.$refs.xTable
  294. const record = {
  295. requirementNo:this.requirementNo,
  296. planNo:this.planNo,
  297. capacityNumber:this.capacityNumber,
  298. orderMaterialList:this.tableData1,
  299. }
  300. const { row: newRow } = await $table.insertAt(record, row)
  301. await $table.setActiveCell(newRow, 'name')
  302. },
  303. //删除行
  304. async removeRow (row) {
  305. const $table = this.$refs.xTable
  306. await $table.remove(row)
  307. },
  308. // 修改
  309. makeSure() {
  310. for(var i=0;i<this.$refs.xTable.getInsertRecords().length;i++){
  311. if(this.$refs.xTable.getInsertRecords()[i].capacityNumber == null){
  312. this.$alert('未选择车牌,请选择车牌')
  313. return
  314. }
  315. }
  316. let BmsTrainFreight = {
  317. planId:Number(this.$route.params.planId),
  318. orderType:11,
  319. carrierId:this.carrierId,
  320. mapList:this.$refs.xTable.getInsertRecords()
  321. };
  322. this.axios
  323. .post("/api/v1/oms/addInwardOrder", BmsTrainFreight)
  324. .then((res) => {
  325. if (res.data.code == 200) {
  326. this.$router.go(-1);
  327. this.$message({
  328. type: "success",
  329. message: "分解成功!",
  330. });
  331. } else {
  332. this.$message.error("分解失败!");
  333. }
  334. });
  335. },
  336. // 返回
  337. cancel() {
  338. this.$router.go(-1);
  339. },
  340. },
  341. };
  342. </script>
  343. <style lang="scss" scoped>
  344. .desomposePlan{
  345. .form-box{
  346. display: inline-block !important;
  347. margin-left: 38%;
  348. .el-input{
  349. width:288px
  350. }
  351. .el-form{
  352. padding: 10px;
  353. }
  354. }
  355. .box-form{
  356. // display: flex;
  357. // justify-content: center;
  358. padding-left: 40.5%;
  359. margin-right: 100px;
  360. .el-form-item__content {
  361. display: flex;
  362. }
  363. }
  364. .capacityButton {
  365. display: flex;
  366. justify-content: center;
  367. align-items: center;
  368. margin-top: 20px;
  369. .truckBtn {
  370. width: 300px;
  371. }
  372. }
  373. .button-box{
  374. display: flex;
  375. justify-content: center;
  376. margin-left: 25px !important;
  377. }
  378. }
  379. </style>