addRequirement2.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  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. var DueTime;
  520. if(this.DueTime==null){
  521. DueTime = null;
  522. }else{
  523. DueTime = sjTime(this.DueTime);
  524. }
  525. let requiremnet = {
  526. requirementEstimatedDuration: this.form.requirementEstimatedDuration,
  527. requirementOverlimit: this.form.requirementOverlimit,
  528. requirementTruckTime: sjTime(this.form.requirementTruckTime),
  529. requirementType: this.form.requirementType,
  530. requirementWorkContent: this.form.requirementWorkContent,
  531. requirementWorkEnvironment: this.form.requirementWorkEnvironment,
  532. requirementWorkType: this.form.requirementWorkType,
  533. requirementShipperId: this.shipperId,
  534. // 用车截日期
  535. DueTime:DueTime,
  536. mapList:this.tableData,
  537. orgCode:getCookie("orgCode")
  538. };
  539. // console.log("requirement",requiremnet);
  540. this.axios
  541. .post("/api/v1/ams/addTruckRequirement", requiremnet)
  542. .then(res => {
  543. if (res.data.code == 200) {
  544. this.$message({
  545. type: "success",
  546. message: "新增成功!"
  547. });
  548. this.$router.go(-1);
  549. } else {
  550. this.$message.error("新增失败!");
  551. }
  552. });
  553. },
  554. // 返回
  555. cancel() {
  556. this.$router.go(-1);
  557. }
  558. }
  559. };
  560. </script>
  561. <style lang="scss">
  562. .inwardRequirement {
  563. .from {
  564. display: flex;
  565. align-items: center;
  566. justify-content: center;
  567. margin-top: 5px;
  568. margin-bottom: 20px;
  569. }
  570. .drawSty{
  571. .el-input{
  572. width: 240px;
  573. }
  574. }
  575. .DueTime{
  576. display: flex;
  577. align-items: center;
  578. justify-content: center;
  579. margin-top: 5px;
  580. margin-bottom: 20px;
  581. .chooseDueTime{
  582. margin-right: 70px;
  583. }
  584. }
  585. .materialDrawer {
  586. display: flex;
  587. justify-content: center;
  588. align-items: center;
  589. .el-input {
  590. width: 320px;
  591. }
  592. .el-select{
  593. width: 320px;
  594. }
  595. .el-autocomplete{
  596. width: 320px;
  597. }
  598. .el-form {
  599. padding: 10px;
  600. }
  601. .truckBtn{
  602. width: 320px;
  603. }
  604. }
  605. .swtichTop{
  606. display: flex;
  607. height: 40px;
  608. align-content: center;
  609. justify-content: center;
  610. padding-right:20px ;
  611. .titile{
  612. color: red;
  613. font-size: 14px;
  614. }
  615. .switch{
  616. margin-right: -30px
  617. }
  618. }
  619. .material {
  620. display: flex;
  621. justify-content: center;
  622. margin-top: 20px;
  623. .text {
  624. display: inline-block;
  625. width: 170px;
  626. text-align: right;
  627. }
  628. .input {
  629. width: 250px;
  630. margin-right: 20px;
  631. }
  632. }
  633. .materialWeight,
  634. .materialNum {
  635. display: flex;
  636. justify-content: center;
  637. margin-top: 20px;
  638. margin-right: 100px;
  639. .text {
  640. display: inline-block;
  641. width: 170px;
  642. text-align: right;
  643. .input {
  644. width: 250px;
  645. margin-right: 20px;
  646. }
  647. }
  648. }
  649. .requireUnit {
  650. display: flex;
  651. justify-content: center;
  652. margin-top: 20px;
  653. margin-right: 127px;
  654. .text {
  655. display: inline-block;
  656. width: 170px;
  657. text-align: right;
  658. .input {
  659. width: 250px;
  660. margin-right: 90px;
  661. }
  662. }
  663. }
  664. .loadPoint,
  665. .unloadPoint {
  666. display: flex;
  667. justify-content: center;
  668. margin-top: 20px;
  669. margin-right: 10px;
  670. .text {
  671. display: inline-block;
  672. width: 170px;
  673. text-align: right;
  674. .input {
  675. width: 250px;
  676. margin-right: 90px;
  677. }
  678. }
  679. }
  680. .form-box {
  681. display: flex;
  682. text-align: center;
  683. align-items: center;
  684. justify-content: center;
  685. margin-top: 20px;
  686. margin-bottom: 20px;
  687. margin-left: -222px;
  688. .el-form-item {
  689. display: flex;
  690. .el-form-item__label {
  691. width: 170px !important;
  692. }
  693. .el-input {
  694. width: 210px !important;
  695. }
  696. }
  697. }
  698. .button-box {
  699. display: flex;
  700. align-items: center;
  701. justify-content: center;
  702. margin-top: 20px;
  703. margin-right: 90px;
  704. }
  705. }
  706. </style>