addRequirement2.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. // 新增厂内内转需求
  2. <template>
  3. <div class="inwardRequirement">
  4. <page-title>新增需求</page-title>
  5. <div>
  6. <!-- 用车单位 -->
  7. <div class="requireUnit form">
  8. <el-form
  9. :inline="true"
  10. class="demo-form-inline"
  11. label-width="80px"
  12. >
  13. <el-form-item label="用车单位">
  14. <el-autocomplete
  15. class="inline-input"
  16. v-model="requireUnitName"
  17. :fetch-suggestions="querySearchCarrier"
  18. placeholder="请输入用车单位名称"
  19. :trigger-on-focus="false"
  20. @select="handleSelectCarrier"
  21. >
  22. <template slot-scope="{ item }">
  23. <div class="name">{{ item.shipperName }}</div>
  24. </template>
  25. </el-autocomplete>
  26. </el-form-item>
  27. </el-form>
  28. </div>
  29. <div class="form-box">
  30. <dil-form :formId="300" v-model="form"></dil-form>
  31. </div>
  32. <div class="materialDrawer">
  33. <el-form
  34. :inline="true"
  35. class="demo-form-inline"
  36. label-width="80px"
  37. >
  38. <el-form-item label="选择物资">
  39. </el-form-item>
  40. <el-form-item >
  41. <el-button type="primary" @click="ondrawer(1)" class="truckBtn"
  42. >浏览</el-button>
  43. </el-form-item>
  44. </el-form>
  45. </div>
  46. <!-- 物资和装卸点以及装卸货次序 -->
  47. <div class="swtichTop">
  48. <span class="titile">点击浏览选择物资之前请选择物资单位!</span>
  49. <div class="switch" v-if="tableData.length > 0">
  50. <el-tooltip placement="top">
  51. <div slot="content">下面表格已有数据,不能进行更改!!!</div>
  52. <el-switch
  53. v-model="value"
  54. active-text="件数"
  55. inactive-text="重量"
  56. disabled
  57. >
  58. </el-switch>
  59. </el-tooltip>
  60. </div>
  61. <div class="switch" v-else>
  62. <el-tooltip placement="top">
  63. <div slot="content">当下面表格有数据之后,将不能进行更改!!!</div>
  64. <el-switch v-model="value" active-text="件数" inactive-text="重量">
  65. </el-switch>
  66. </el-tooltip>
  67. </div>
  68. </div>
  69. <!-- 物资表格 -->
  70. <div class="truckListTable">
  71. <div class="selectionTable">
  72. <el-table
  73. :data="tableData"
  74. border
  75. style="width: 100%"
  76. highlight-current-row
  77. >
  78. <el-table-column
  79. v-for="(item, i) in tableTop"
  80. :key="i"
  81. :prop="item.prop"
  82. :label="item.label"
  83. align="center"
  84. show-overflow-tooltip
  85. >
  86. <template slot="scope" v-if="item.label !== '件数'">
  87. <span>{{ item.label }}</span>
  88. </template>
  89. <!-- 插入输入框 -->
  90. <template slot-scope="scope">
  91. <template v-if="item.slot">
  92. <!-- 装货点 -->
  93. <template v-if="item.prop == 'requirementPlatformName'">
  94. <el-input
  95. class="textinput"
  96. v-model="scope.row.requirementPlatformName"
  97. disabled
  98. ></el-input>
  99. </template>
  100. <!-- 卸货点 -->
  101. <template v-if="item.prop == 'truckPoint1'">
  102. <el-input
  103. class="textinput"
  104. v-model="scope.row.truckPoint1"
  105. disabled
  106. ></el-input>
  107. </template>
  108. <!-- 装卸货优先级 -->
  109. <template v-if="item.prop == 'materialPriority'">
  110. <el-input
  111. class="textinput"
  112. v-model.number="scope.row.materialPriority"
  113. @input="onInputPriority(scope.row.materialPriority)"
  114. ></el-input>
  115. </template>
  116. <!-- 物资件数 -->
  117. <template v-if="item.prop == 'orderMaterialNumber'">
  118. <el-input
  119. class="textinput"
  120. v-model.number="scope.row.orderMaterialNumber"
  121. @input="onInputNumber(scope.row.orderMaterialNumber)"
  122. ></el-input>
  123. </template>
  124. <!-- 物资重量 -->
  125. <template v-if="item.prop == 'orderMaterialWeight'">
  126. <el-input
  127. v-model.number="scope.row.orderMaterialWeight"
  128. @input="onInputWeight(scope.row.orderMaterialWeight)"
  129. ></el-input>
  130. </template>
  131. </template>
  132. <template v-else>
  133. <span>{{ scope.row[item.prop] }}</span>
  134. </template>
  135. </template>
  136. </el-table-column>
  137. <!-- 操作列 -->
  138. <el-table-column fixed="right" label="操作" width="250">
  139. <template slot-scope="scope">
  140. <el-button type="primary" @click="loadPoint(scope.$index)">装货点</el-button>
  141. <el-button type="primary" @click="unloadPoint(scope.$index)">卸货点</el-button>
  142. <el-button
  143. @click.native.prevent="deleteRow(scope.$index, tableData)"
  144. type="text"
  145. icon="el-icon-close"
  146. size="big"
  147. ></el-button>
  148. </template>
  149. </el-table-column>
  150. </el-table>
  151. </div>
  152. </div>
  153. <!-- 物资模态框 -->
  154. <div class="drawSty">
  155. <el-drawer
  156. title="选择物资信息"
  157. :visible.sync="table"
  158. direction="rtl"
  159. size="40%"
  160. :show-close="false"
  161. >
  162. <el-input placeholder="请输入内容" v-model="inputMaterial" clearable > </el-input
  163. ><el-button type="primary" class="btn" @click="onclickMaterial">
  164. <i class="el-icon-search"></i>查询
  165. </el-button>
  166. <!-- <el-button @click="open">取消</el-button> -->
  167. <el-button type="primary" @click="makeSure1">确定</el-button>
  168. <div class="tablecls">
  169. <!-- 查询所有的物资 -->
  170. <dilTable ref="materialTable" v-bind.sync="materialTable" @selection-change="selectionChange" :drawer="aaadrawer">
  171. </dilTable>
  172. </div>
  173. </el-drawer>
  174. </div>
  175. <el-drawer
  176. :visible.sync="drawer"
  177. :direction="direction"
  178. :before-close="handleClose"
  179. size="30%"
  180. >
  181. <el-input
  182. placeholder="请输入内容"
  183. v-model="input"
  184. style="margin-top: 10px; margin-left: 10px; width: 250px"
  185. clearable
  186. >
  187. </el-input>
  188. <el-button
  189. type="primary"
  190. class="btn"
  191. @click="onclick(a)"
  192. style="margin-bottom: 15px"
  193. >
  194. <i class="el-icon-search"></i>查询
  195. </el-button>
  196. <div v-show="a == 2">
  197. <dilTable
  198. v-bind.sync="second1"
  199. @radio-change="currentRadioChange2"
  200. ></dilTable>
  201. </div>
  202. <div v-show="a == 3">
  203. <dilTable
  204. v-bind.sync="second1"
  205. @radio-change="currentRadioChange2"
  206. ></dilTable>
  207. </div>
  208. <div v-show="a == 4">
  209. <dilTable
  210. v-bind.sync="second1"
  211. @radio-change="currentRadioChange2"
  212. ></dilTable>
  213. </div>
  214. </el-drawer>
  215. </div>
  216. <div class="button-box">
  217. <el-button type="primary" @click="makeSure">确认新增</el-button>
  218. <el-button type="primary" @click="cancel">返回</el-button>
  219. </div>
  220. </div>
  221. </template>
  222. <script>
  223. import PageTitle from "@/components/Page/Title";
  224. import { sjTime } from "@/utils/sharedJsFile";
  225. import { getCookie } from "@/utils/util.js";
  226. export default {
  227. components: { PageTitle },
  228. data() {
  229. return {
  230. aaadrawer:false,
  231. disabled:false,
  232. options: [],
  233. value: '',
  234. // 件数与重量的开关
  235. value: false,
  236. //物资模态框开关
  237. table: false,
  238. //物资表格表头
  239. tableTop: [
  240. {
  241. prop: "materialName",
  242. label: "物资名称",
  243. width: "140",
  244. },
  245. {
  246. prop: "requirementPlatformName",
  247. label: "装货点",
  248. slot:true,
  249. width: "140",
  250. },
  251. {
  252. prop: "truckPoint1",
  253. label: "卸货点",
  254. slot:true,
  255. width: "140",
  256. },
  257. {
  258. prop: "orderMaterialWeight",
  259. label: "重量",
  260. slot: true,
  261. },
  262. ],
  263. row: {},
  264. //物资表格数据
  265. tableData: [],
  266. materialName: null,
  267. requirementPlatformName: null,
  268. materialNum:null,
  269. materialWeight:null,
  270. a: 1,
  271. index:null,
  272. direction: "rtl",
  273. input:null,
  274. requiremntUnitId: null,
  275. requirementUnloadUnitId: null,
  276. requirementPlatformId: null,
  277. truckPoint: "",
  278. materialId: null,
  279. requireUnitName:null,
  280. inputMaterial:null,
  281. shipperId:null,
  282. truckPoint1: "",
  283. drawer: false,
  284. selectionList1: [],
  285. form: {},
  286. materialTable: {
  287. requestUrl: "",
  288. selectionType: "select",
  289. mapList1: []
  290. },
  291. second1: {
  292. requestUrl: "/api/v1/ams/getWareHouse?apiId=251",
  293. selectionType: "radio",
  294. mapList2: []
  295. }
  296. };
  297. },
  298. watch: {
  299. value() {
  300. if (this.value) {
  301. console.log(this.value)
  302. console.log(this.tableTop.length)
  303. this.tableTop.splice(this.tableTop.length - 1, 1);
  304. this.tableTop.push({
  305. prop: "orderMaterialNumber",
  306. label: "件数",
  307. slot: true,
  308. });
  309. } else {
  310. this.tableTop.splice(this.tableTop.length - 1, 1);
  311. this.tableTop.push({
  312. prop: "orderMaterialWeight",
  313. label: "重量",
  314. slot: true,
  315. });
  316. }
  317. },
  318. table(val){
  319. if(val){
  320. this.aaadrawer = false;
  321. }else{
  322. this.aaadrawer = true;
  323. }
  324. }
  325. },
  326. methods: {
  327. //用车单位弹出层
  328. handleSelectCarrier(item){
  329. this.shipperId = item.shipperId
  330. this.requireUnitName = item.shipperName
  331. },
  332. //以下是用车单位边输边查搜索
  333. querySearchCarrier(queryString, cb) {
  334. this.axios.post('/api/v1/uc/getRequireUnitName?index='+queryString).then((res)=>{
  335. if(res.data.code == "200"){
  336. var restaurantsCarrier = res.data.data
  337. console.log(restaurantsCarrier,"restaurantsCarrier");
  338. var results = queryString ? restaurantsCarrier.filter(this.createFilterCarrier(queryString)) :restaurantsCarrier;
  339. // 调用 callback 返回建议列表的数据
  340. cb(results);
  341. }
  342. })
  343. },
  344. createFilterCarrier(queryString) {
  345. return (restaurantsCarrier) => {
  346. return (restaurantsCarrier.shipperName.toLowerCase().indexOf(queryString.toLowerCase()) > -1);
  347. };
  348. },
  349. // 返回选中的物资信息
  350. selectionChange(selection) {
  351. this.selectionList1 = [];
  352. this.selectionList1 = selection;
  353. },
  354. unloadPoint(index) {
  355. console.log(index)
  356. this.index= index
  357. this.a = 3
  358. this.drawer = true;
  359. },
  360. loadPoint(index) {
  361. console.log(index)
  362. this.index = index
  363. this.a = 4
  364. this.drawer = true;
  365. },
  366. //以上是用车单位边输边查搜索
  367. ondrawer(num) {
  368. if(num==1){
  369. this.table = true
  370. this.materialTable.requestUrl = "/api/v1/uc/queryMaterialByLike?apiId=244&i=" + new Date()
  371. }else{
  372. this.drawer = true;
  373. }
  374. this.a = num;
  375. },
  376. handleClose(done) {
  377. done();
  378. },
  379. //删除行
  380. deleteRow(index, rows) {
  381. console.log(index)
  382. console.log("这里")
  383. rows.splice(index, 1);
  384. },
  385. // 返回主界面
  386. makeSure1() {
  387. this.selectionList1.forEach((e) => {
  388. console.log(e.materialModel,e.materialSpecification)
  389. if(e.materialSpecification == null){
  390. e.materialSpecification = ''
  391. }
  392. if(e.materialModel == null){
  393. e.materialModel = ''
  394. }
  395. var addmap = {
  396. materialName: e.materialName + e.materialSpecification+e.materialModel,
  397. materialId: e.materialId,
  398. };
  399. this.tableData.push(addmap);
  400. });
  401. this.selectionList1 = [];
  402. this.table = false;
  403. },
  404. refreshTable(){
  405. var arr = this.tableData
  406. this.tableData = []
  407. arr.forEach((e) => {
  408. var addmap = {
  409. materialName : e.materialName,
  410. materialId: e.materialId,
  411. requirementPlatformName:e.requirementPlatformName,
  412. truckPoint1:e.truckPoint1,
  413. requirementPlatformId:e.requirementPlatformId,
  414. requirementUnloadUnitId:e.requirementUnloadUnitId,
  415. orderMaterialNumber:e.orderMaterialNumber,
  416. orderMaterialWeight:e.orderMaterialWeight
  417. };
  418. this.tableData.push(addmap)
  419. })
  420. },
  421. onclick(a) {
  422. if(this.input != null){
  423. if (a == 1) {
  424. this.materialTable.requestUrl =
  425. "/api/v1/uc/queryMaterialByLike?apiId=244&index=" + this.input;
  426. this.input = null
  427. } else {
  428. this.second1.requestUrl =
  429. "/api/v1/ams/getWareHouse?apiId=251&con=" + this.input;
  430. this.input = null
  431. }
  432. }else{
  433. this.materialTable.requestUrl = "/api/v1/uc/queryMaterialByLike?apiId=244&i=" + new Date()
  434. }
  435. },
  436. currentRadioChange1(selection) {
  437. this.mapList1 = selection;
  438. console.log(selection)
  439. if(selection.materialSpecification==null||selection.materialModel==null){
  440. this.materialName = this.mapList1.materialName
  441. }else{
  442. this.materialName = this.mapList1.materialName + selection.materialSpecification + '(' + selection.materialModel + ')';
  443. }
  444. this.materialId = selection.materialId;
  445. },
  446. currentRadioChange2(selection) {
  447. if (this.a == 2) {
  448. this.truckPoint = selection.wareHouseName;
  449. this.requiremntUnitId = selection.wareHouseId;
  450. } else if (this.a == 3) {
  451. console.log(this.tableData[this.index])
  452. this.tableData[this.index].requirementUnloadUnitId = selection.wareHouseId;
  453. this.tableData[this.index].truckPoint1 = selection.wareHouseName
  454. this.refreshTable()
  455. } else if (this.a == 4) {
  456. console.log(this.tableData[this.index])
  457. this.tableData[this.index].requirementPlatformId = selection.wareHouseId;
  458. this.tableData[this.index].requirementPlatformName = selection.wareHouseName;
  459. this.refreshTable()
  460. }
  461. },
  462. // 新增
  463. makeSure() {
  464. console.log(this.tableData)
  465. console.log(typeof(this.form.requirementEstimatedDuration))
  466. if(this.shipperId == null){
  467. this.$message.error("请选择用车单位")
  468. return
  469. }if(typeof(this.form.requirementEstimatedDuration) == 'undefined'){
  470. this.$message.error("请输入预计用车时长")
  471. return
  472. }if(typeof(this.form.requirementTruckTime) == 'undefined'){
  473. this.$message.error("请输入用车时间")
  474. return
  475. }if(typeof(this.form.requirementType) == 'undefined'){
  476. this.$message.error("请选择需求类型")
  477. return
  478. }if(typeof(this.form.requirementWorkType) == 'undefined'){
  479. this.$message.error("请输入费用类别")
  480. return
  481. }if(this.tableData.length == 0){
  482. this.$message.error("请点击浏览选择物资")
  483. return
  484. }
  485. var i=0
  486. this.tableData.forEach((e) =>{
  487. if(e.requirementPlatformId&&e.requirementUnloadUnitId){
  488. i++
  489. }
  490. })
  491. if(i==0){
  492. this.$message.error("请选择装卸点")
  493. return
  494. }
  495. console.log(this.tableData)
  496. debugger
  497. let requiremnet = {
  498. requirementEstimatedDuration: this.form.requirementEstimatedDuration,
  499. requirementOverlimit: this.form.requirementOverlimit,
  500. requirementTruckTime: sjTime(this.form.requirementTruckTime),
  501. requirementType: this.form.requirementType,
  502. requirementWorkContent: this.form.requirementWorkContent,
  503. requirementWorkEnvironment: this.form.requirementWorkEnvironment,
  504. requirementWorkType: this.form.requirementWorkType,
  505. requirementShipperId: this.shipperId,
  506. mapList:this.tableData,
  507. orgCode:getCookie("orgCode")
  508. };
  509. this.axios
  510. .post("/api/v1/ams/addTruckRequirement", requiremnet)
  511. .then(res => {
  512. if (res.data.code == 200) {
  513. this.$message({
  514. type: "success",
  515. message: "新增成功!"
  516. });
  517. this.$router.go(-1);
  518. } else {
  519. this.$message.error("新增失败!");
  520. }
  521. });
  522. },
  523. // 返回
  524. cancel() {
  525. this.$router.go(-1);
  526. }
  527. }
  528. };
  529. </script>
  530. <style lang="scss">
  531. .inwardRequirement {
  532. .from {
  533. display: flex;
  534. align-items: center;
  535. justify-content: center;
  536. margin-top: 5px;
  537. margin-bottom: 20px;
  538. }
  539. .drawSty{
  540. .el-input{
  541. width: 240px;
  542. }
  543. }
  544. .materialDrawer {
  545. display: flex;
  546. justify-content: center;
  547. align-items: center;
  548. .el-input {
  549. width: 320px;
  550. }
  551. .el-select{
  552. width: 320px;
  553. }
  554. .el-autocomplete{
  555. width: 320px;
  556. }
  557. .el-form {
  558. padding: 10px;
  559. }
  560. .truckBtn{
  561. width: 320px;
  562. }
  563. }
  564. .swtichTop{
  565. display: flex;
  566. height: 40px;
  567. align-content: center;
  568. justify-content: center;
  569. padding-right:20px ;
  570. .titile{
  571. color: red;
  572. font-size: 14px;
  573. }
  574. .switch{
  575. margin-right: -60px
  576. }
  577. }
  578. .material {
  579. display: flex;
  580. justify-content: center;
  581. margin-top: 20px;
  582. .text {
  583. display: inline-block;
  584. width: 170px;
  585. text-align: right;
  586. }
  587. .input {
  588. width: 250px;
  589. margin-right: 20px;
  590. }
  591. }
  592. .materialWeight,
  593. .materialNum {
  594. display: flex;
  595. justify-content: center;
  596. margin-top: 20px;
  597. margin-right: 100px;
  598. .text {
  599. display: inline-block;
  600. width: 170px;
  601. text-align: right;
  602. .input {
  603. width: 250px;
  604. margin-right: 20px;
  605. }
  606. }
  607. }
  608. .requireUnit {
  609. display: flex;
  610. justify-content: center;
  611. margin-top: 20px;
  612. margin-right: 127px;
  613. .text {
  614. display: inline-block;
  615. width: 170px;
  616. text-align: right;
  617. .input {
  618. width: 250px;
  619. margin-right: 90px;
  620. }
  621. }
  622. }
  623. .loadPoint,
  624. .unloadPoint {
  625. display: flex;
  626. justify-content: center;
  627. margin-top: 20px;
  628. margin-right: 10px;
  629. .text {
  630. display: inline-block;
  631. width: 170px;
  632. text-align: right;
  633. .input {
  634. width: 250px;
  635. margin-right: 90px;
  636. }
  637. }
  638. }
  639. .form-box {
  640. display: flex;
  641. text-align: center;
  642. align-items: center;
  643. justify-content: center;
  644. margin-top: 20px;
  645. margin-bottom: 20px;
  646. margin-right: 212px;
  647. .el-form-item {
  648. display: flex;
  649. .el-form-item__label {
  650. width: 170px !important;
  651. }
  652. .el-input {
  653. width: 210px !important;
  654. }
  655. }
  656. }
  657. .button-box {
  658. display: flex;
  659. align-items: center;
  660. justify-content: center;
  661. margin-top: 20px;
  662. margin-right: 90px;
  663. }
  664. }
  665. </style>