addRequirement2.vue 20 KB

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