addPlan.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. // 新增计划
  2. <template>
  3. <div class="addInwardPlan">
  4. <page-title>新增计划</page-title>
  5. <div class="carrier form">
  6. <el-form class="demo-form-inline" label-width="80px" label-position="left">
  7. <el-form-item label="承运商">
  8. <el-autocomplete
  9. class="inline-input"
  10. v-model="state2"
  11. :fetch-suggestions="querySearch"
  12. placeholder="请输入承运商名称"
  13. :trigger-on-focus="false"
  14. @select="handleSelect"
  15. >
  16. <template slot-scope="{ item }">
  17. <div class="name">{{ item.value }}</div>
  18. </template>
  19. </el-autocomplete>
  20. </el-form-item>
  21. <div class="truckNum">
  22. <el-form class="demo-form-inline" label-width="80px" label-position="left">
  23. <el-form-item label="车数">
  24. <el-input v-model="planTruckNumber" placeholder="必填" class="input"></el-input>
  25. </el-form-item>
  26. </el-form>
  27. </div>
  28. </el-form>
  29. </div>
  30. <template>
  31. <div>
  32. <dilTable v-bind.sync="first" @radio-change="currentRadioChange" ref="table">
  33. <el-table-column fixed="right" label="操作" width="120">
  34. <template slot-scope="scope">
  35. <el-button type="text" size="mini" @click="getRequirementMaterial(scope.row)">
  36. 物资详情
  37. </el-button>
  38. </template>
  39. </el-table-column>
  40. <!-- 物资详情抽屉 -->
  41. <el-table-column type="expand" width="1">
  42. <template slot-scope="props">
  43. <el-form label-position="center" inline class="demo-table-expand">
  44. <div v-if="false">{{ props }}</div>
  45. <div>
  46. <el-table :data="tableData" border >
  47. <el-table-column
  48. v-for="(item, i) in tableHead"
  49. :key="i"
  50. :prop="item.prop"
  51. :label="item.label"
  52. :width="item.width"
  53. ></el-table-column>
  54. </el-table>
  55. </div>
  56. </el-form>
  57. </template>
  58. </el-table-column>
  59. </dilTable>
  60. </div>
  61. </template>
  62. <div class="button-box">
  63. <el-button type="primary" @click="makeSure">确认新增</el-button>
  64. <el-button type="primary" @click="cancel">返回</el-button>
  65. </div>
  66. </div>
  67. </template>
  68. <script>
  69. import PageTitle from "@/components/Page/Title";
  70. export default {
  71. components: { PageTitle },
  72. data() {
  73. return {
  74. restaurants: [],
  75. state2:null,
  76. planTruckNumber:null,
  77. carrierId:null,
  78. requirementId:null,
  79. form: {},
  80. first:{
  81. requestUrl:"/api/v1/ams/getTruckRequirementList?apiId=250&requirementStatus=2",
  82. selectionType: "radio",
  83. mapList: {},
  84. },
  85. numberValidateForm: {
  86. planTruckNumber: null,
  87. },
  88. //记录旧的row对象(未下发)
  89. oldRow: "",
  90. //记录上一个展开的点击次数,单数为展开状态,复数为闭合状态(未下发)
  91. oldRowCount: 1,
  92. //记录旧的row对象(已下发)
  93. oldRow1: "",
  94. //记录上一个展开的点击次数,单数为展开状态,复数为闭合状态(已下发)
  95. oldRowCount1: 1,
  96. tableHead: [
  97. {
  98. prop: "materialName",
  99. label: "物资名称",
  100. width: 150,
  101. },
  102. {
  103. prop:"loadName",
  104. label:"装货点",
  105. width:150
  106. },
  107. {
  108. prop:"unloadName",
  109. label:"卸货点",
  110. width:150
  111. },
  112. {
  113. prop:"loadSequence",
  114. label:"装卸货次序",
  115. width:150
  116. },
  117. {
  118. prop: "materialWeight",
  119. label: "物资重量",
  120. width: 150,
  121. },
  122. {
  123. prop: "materialCount",
  124. label: "物资数量",
  125. width: 150,
  126. },
  127. ],
  128. tableData: [],
  129. tableData1: [],
  130. };
  131. },
  132. methods: {
  133. getRequirementMaterial(row) {
  134. // 记录重复点击次数
  135. if (this.oldRow === row) {
  136. this.oldRowCount += 1;
  137. }
  138. // 切换当前详情表
  139. this.$refs.table.toggleRowExpansion(row);
  140. // 打开前关闭上一个详情表
  141. if (this.oldRow != "") {
  142. if (this.oldRow != row) {
  143. if (this.oldRowCount % 2 === 1) {
  144. this.$refs.table.toggleRowExpansion(this.oldRow);
  145. } else {
  146. this.oldRowCount = 1;
  147. }
  148. } else {
  149. this.oldRow = null;
  150. return;
  151. }
  152. }
  153. // 重置上一个点击对象
  154. this.oldRow = row;
  155. this.getMaterial(row.requirementId);
  156. },
  157. getMaterial(requirementId){
  158. console.log(requirementId)
  159. this.axios.post("/api/v1/ams/getRequirementMaterial/" + requirementId).then((res) => {
  160. this.tableData = res.data.data
  161. console.log(res.data.data)
  162. })
  163. },
  164. handleSelect(item){
  165. this.carrierId = item.carrierId
  166. this.state2 = item.carrierName
  167. },
  168. //搜索
  169. querySearch(queryString, cb) {
  170. this.axios.post('/api/v1/uc/getCarrierMesByLike?index='+this.state2).then((res)=>{
  171. if(res.data.code == "200"){
  172. console.log(res)
  173. var restaurants = res.data.data
  174. var results = queryString ? restaurants.filter(this.createFilter(queryString)) :restaurants;
  175. // 调用 callback 返回建议列表的数据
  176. console.log(results,"results");
  177. cb(results);
  178. }
  179. })
  180. },
  181. createFilter(queryString) {
  182. return (restaurants) => {
  183. return (restaurants.value.toLowerCase().indexOf(queryString.toLowerCase()) > -1);
  184. };
  185. },
  186. currentRadioChange(selection){
  187. this.mapList = selection
  188. this.requirementId = selection.requirementId
  189. console.log(this.mapList)
  190. },
  191. // 新增
  192. makeSure() {
  193. console.log(typeof(this.planTruckNumber))
  194. if(this.carrierId == null){
  195. this.$alert('请输入承运商!')
  196. return
  197. }else if(this.planTruckNumber == null){
  198. this.$alert('请输入车数!')
  199. return
  200. }else if(this.requirementId== null){
  201. this.$alert('请选择需要制定计划的需求!')
  202. return
  203. }
  204. let plan = {
  205. requirementId : this.mapList.requirementId,
  206. planTruckNumber: this.planTruckNumber,
  207. carrierId: this.carrierId
  208. };
  209. this.axios
  210. .post(
  211. "/api/v1/ams/addTruckPlan",
  212. plan
  213. )
  214. .then((res) => {
  215. console.log(res)
  216. if (res.data.code == 200) {
  217. this.$message({
  218. type: "success",
  219. message: "新增成功!",
  220. });
  221. this.$router.go(-1);
  222. } else {
  223. this.$message.error("新增失败!");
  224. }
  225. });
  226. },
  227. // 返回
  228. cancel() {
  229. this.$router.go(-1);
  230. },
  231. },
  232. };
  233. </script>
  234. <style lang="scss" scoped>
  235. .addInwardPlan{
  236. .carrier{
  237. display: inline-block !important;
  238. margin-left: 38%;
  239. .el-input{
  240. width:250px
  241. }
  242. .input{
  243. margin-left: -10px;
  244. }
  245. .el-form{
  246. padding: 10px;
  247. }
  248. }
  249. .truckNum {
  250. .el-input{
  251. width: 250px;
  252. }
  253. }
  254. .button-box
  255. {
  256. display: flex;
  257. justify-content: center;
  258. margin-left: 25px !important;
  259. }
  260. }
  261. </style>