updateSaleOrderSteel.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. <template>
  2. <div class="updateSteelDetails">
  3. <!-- 车牌号查询框 -->
  4. <div class="top">
  5. <el-input
  6. v-model="inputCapacity"
  7. placeholder="请输入车牌号"
  8. clearable
  9. ></el-input>
  10. <el-button type="primary" @click="onclick">查询</el-button>
  11. <el-button type="primary" @click="back">返回</el-button>
  12. </div>
  13. <!-- //物资模态框多选 -->
  14. <div class="edrwer">
  15. <!-- 物资选择模态框 -->
  16. <el-drawer
  17. title="选择物资信息"
  18. :visible.sync="table1"
  19. direction="rtl"
  20. size="90%"
  21. :show-close="true"
  22. >
  23. <el-form :inline="true" style="margin-top: 0.5rem;">
  24. <el-form-item>
  25. <label class="el-form-item__label" style="width: auto;"
  26. >物资名称/型号</label
  27. >
  28. </el-form-item>
  29. <el-form-item>
  30. <el-input
  31. placeholder="请输入物资名称或型号"
  32. v-model="materialNameText"
  33. clearable
  34. ></el-input>
  35. </el-form-item>
  36. <el-form-item>
  37. <label class="el-form-item__label" style="width: auto;">规格</label>
  38. </el-form-item>
  39. <el-form-item>
  40. <el-input
  41. placeholder="请输入内容"
  42. v-model="materialSpecificationText"
  43. clearable
  44. ><template slot="prepend">Φ</template></el-input
  45. >
  46. </el-form-item>
  47. <el-button
  48. type="primary"
  49. class="btn"
  50. @click="onclick"
  51. style="margin-left: 4px;"
  52. ><i class="el-icon-search"></i>查询</el-button
  53. >
  54. <el-button type="primary" @click="makeSureMaterial"
  55. ><i class="el-icon-check"></i>确定</el-button
  56. >
  57. </el-form>
  58. <div class="tablecls">
  59. <!-- 查询所有的物资 -->
  60. <dilTable
  61. v-bind.sync="option"
  62. @selection-change="selectionChange"
  63. @rowDbClick="rowDbClick"
  64. >
  65. </dilTable>
  66. </div>
  67. </el-drawer>
  68. </div>
  69. <div class="table">
  70. <el-table
  71. :data="tableData"
  72. style="width: 100%"
  73. :span-method="objectSpanMethod"
  74. border
  75. key="orderTable"
  76. >
  77. <el-table-column
  78. width="50"
  79. label="序号"
  80. align="center"
  81. fixed="left"
  82. :resizable="false"
  83. >
  84. <template slot-scope="scope">{{ scope.row.group + 1 }}</template>
  85. </el-table-column>
  86. <el-table-column property="capacityNumber" label="车牌号" width="120">
  87. </el-table-column>
  88. <el-table-column property="consigneeCompanyName" label="收货单位">
  89. </el-table-column>
  90. <el-table-column property="completeAddress" label="收货地址">
  91. </el-table-column>
  92. <el-table-column property="carrierName" label="承运商">
  93. </el-table-column>
  94. <el-table-column property="materialName" label="物资名称">
  95. </el-table-column>
  96. <el-table-column property="materialSpecification" label="规格">
  97. </el-table-column>
  98. <el-table-column property="materialModel" label="型号">
  99. </el-table-column>
  100. <el-table-column fixed="right" label="操作" width="200">
  101. <template slot-scope="scope">
  102. <el-button type="text" size="mini" @click="updateMaterial(scope)">
  103. 物资异常
  104. </el-button>
  105. <el-button type="text" size="mini" @click="updateAddress(scope)">
  106. 收货地址异常
  107. </el-button>
  108. </template>
  109. </el-table-column>
  110. </el-table>
  111. </div>
  112. <div class="dialog">
  113. <el-dialog
  114. :title="title"
  115. :visible.sync="dialogTableVisible"
  116. style="width:100%"
  117. >
  118. <div class="errorMaterial">
  119. <el-button @click="openDrawer" type="primary">新增拼数</el-button>
  120. </div>
  121. <div class="">
  122. <el-table
  123. :data="materialList"
  124. border
  125. :span-method="objectSpanMethod1"
  126. highlight-current-row
  127. key="materialTable"
  128. >
  129. <el-table-column
  130. v-for="(item, i) in materialTableTop"
  131. :key="i"
  132. :prop="item.prop"
  133. :label="item.label"
  134. align="center"
  135. show-overflow-tooltip
  136. >
  137. <!-- 插入输入框 -->
  138. <template slot-scope="scope">
  139. <template v-if="item.slot">
  140. <!-- 物资名称 -->
  141. <template v-if="item.prop == 'materialName'">
  142. <el-input
  143. style="width: 200px"
  144. v-model="scope.row.materialName"
  145. disabled
  146. >
  147. </el-input>
  148. </template>
  149. <!-- 物资件数 -->
  150. <template v-if="item.prop == 'orderPlanWeight'">
  151. <el-input
  152. class="textinput111"
  153. v-model.number="scope.row.orderPlanWeight"
  154. placeholder="(必填)"
  155. ></el-input>
  156. </template>
  157. <!-- 米数 -->
  158. <template v-if="item.prop == 'meterNumber'">
  159. <el-input
  160. :disabled="scope.row.isDisable == 1"
  161. class="textinput111"
  162. v-model.number="scope.row.meterNumber"
  163. placeholder="(必填)"
  164. ></el-input>
  165. </template>
  166. <!-- 是否磅重销售 -->
  167. <template v-if="item.prop == 'isPound'">
  168. <el-select
  169. v-model="scope.row.isPound"
  170. placeholder="请选择"
  171. style="width:65px"
  172. >
  173. <el-option
  174. v-for="item in options2"
  175. :key="item.values2"
  176. :label="item.label2"
  177. :value="item.values2"
  178. >
  179. </el-option>
  180. </el-select>
  181. </template>
  182. </template>
  183. <template v-else>
  184. <span>{{ scope.row[item.prop] }}</span>
  185. </template>
  186. </template>
  187. </el-table-column>
  188. <!-- 操作列 -->
  189. <el-table-column fixed="right" label="操作" width="100">
  190. <template slot-scope="scope">
  191. <el-button
  192. @click.native.prevent="
  193. deleteMaterialRow(scope.$index, materialList)
  194. "
  195. type="text"
  196. icon="el-icon-close"
  197. size="big"
  198. ></el-button>
  199. </template>
  200. </el-table-column>
  201. </el-table>
  202. </div>
  203. <div class="buttonx">
  204. <el-button type="primary" @click="makeSureUpdateMaterial"
  205. >确定</el-button
  206. >
  207. <el-button type="primary" @click="cancelUpdateMaterial"
  208. >取消</el-button
  209. >
  210. </div>
  211. </el-dialog>
  212. </div>
  213. </div>
  214. </template>
  215. <script>
  216. export default {
  217. data() {
  218. return {
  219. title: "",
  220. capacityNumber: null,
  221. //是否磅重销售
  222. options2: [
  223. {
  224. values2: 0,
  225. label2: "是"
  226. },
  227. {
  228. values2: 1,
  229. label2: "否"
  230. }
  231. ],
  232. table1: false,
  233. isDelete: false,
  234. dialogTableVisible: false,
  235. inputCapacity: null,
  236. tableData: [],
  237. tableData1: [],
  238. materialList1: [],
  239. materialList: [],
  240. //存放每一行记录的合并数
  241. spanArr: [],
  242. spanArr1: [],
  243. status: null,
  244. //物资表格多选
  245. option: {
  246. // 表格请求数据的地址
  247. requestUrl: "/api/v1/uc/getSteelMaterial?apiId=244",
  248. // 控制显示多选列
  249. selectionType: "select"
  250. },
  251. materialSpecificationText: null,
  252. materialNameText: null,
  253. spanArr: [],
  254. materialTableTop: [
  255. {
  256. prop: "capacityNumber",
  257. label: "车牌号",
  258. width: "80"
  259. },
  260. {
  261. prop: "materialName",
  262. label: "物资名称",
  263. width: "90",
  264. slot: true
  265. },
  266. {
  267. prop: "meterNumber",
  268. label: "米数",
  269. width: "60",
  270. slot: true
  271. },
  272. {
  273. prop: "Specification",
  274. label: "规格型号",
  275. width: "140"
  276. },
  277. {
  278. prop: "orderPlanWeight",
  279. label: "件数",
  280. width: "60",
  281. slot: true
  282. },
  283. {
  284. prop: "isPound",
  285. label: "是否磅重销售",
  286. width: "80",
  287. slot: true
  288. }
  289. ],
  290. orderId: null
  291. };
  292. },
  293. mounted() {
  294. this.getOrderList();
  295. },
  296. methods: {
  297. updateAddress(scope) {},
  298. cancelUpdateMaterial() {
  299. this.dialogTableVisible = false;
  300. },
  301. makeSureUpdateMaterial() {
  302. let i = 0;
  303. if (this.materialList.length == 0) {
  304. this.$message.error("物资信息不能为空");
  305. return;
  306. }
  307. this.materialList.forEach(e => {
  308. if (!/(^[1-9]\d*$)/.test(e.meterNumber) && e.meterNumber != null) {
  309. e.meterNumber = null;
  310. i++;
  311. }
  312. });
  313. if (i != 0) {
  314. i = 0;
  315. this.$message.error("米数请输入正整数");
  316. return;
  317. }
  318. this.materialList.forEach(e => {
  319. if (!/(^[1-9]\d*$)/.test(e.orderPlanWeight)) {
  320. e.orderPlanWeight = null;
  321. i++;
  322. }
  323. });
  324. if (i != 0) {
  325. this.$message.error("件数必填且请输入正整数");
  326. return;
  327. }
  328. this.dialogTableVisible = false;
  329. this.orderId = null;
  330. this.saleOrderMaterialId = null;
  331. this.saleOrderId = this.$route.params.saleOrderId;
  332. this.materialList.forEach(e => {
  333. this.orderId = e.orderId;
  334. this.saleOrderMaterialId = e.saleOrderMaterialId;
  335. });
  336. let mapVal = {
  337. orderId: this.orderId,
  338. saleOrderMaterialId: this.saleOrderMaterialId,
  339. saleOrderId: this.saleOrderId,
  340. mapList: this.materialList
  341. };
  342. this.axios
  343. .post("/api/v1/ams/updateAllMaterialInSale", mapVal)
  344. .then(res => {
  345. console.log(res);
  346. });
  347. },
  348. makeSureMaterial() {
  349. //记录是理重还是磅重
  350. var getisPound = 1;
  351. this.materialList1.forEach(e => {
  352. if (!e.materialSpecification) {
  353. e.materialSpecification = "";
  354. }
  355. if (!e.materialModel) {
  356. e.materialModel = "";
  357. }
  358. //判断物资是否为盘螺或非定尺
  359. if (
  360. e.materialName.includes("盘螺") ||
  361. e.materialName.includes("乱尺") ||
  362. e.materialName.includes("盘元") ||
  363. e.materialName.includes("盘圆")
  364. ) {
  365. getisPound = 0;
  366. } else {
  367. getisPound = 1;
  368. }
  369. //若物资为带有盘螺、盘圆、盘元,默认无米数
  370. if (
  371. e.materialName.includes("盘螺") ||
  372. e.materialName.includes("盘圆") ||
  373. e.materialName.includes("盘元")
  374. ) {
  375. var addmap = {
  376. orderId: this.orderId,
  377. capacityNumber: this.capacityNumber,
  378. materialName: e.materialName,
  379. Specification: e.materialSpecification + e.materialModel,
  380. materialCode: e.materialCode,
  381. orderPlanWeight: null,
  382. meterNumber: null,
  383. isPound: getisPound,
  384. //物资Id
  385. materialId: e.materialId
  386. };
  387. } else {
  388. if (e.materialName.includes("米")) {
  389. console.log("着");
  390. var addmap = {
  391. capacityNumber: this.capacityNumber,
  392. orderId: this.orderId,
  393. materialName: e.materialName,
  394. Specification: e.materialSpecification + e.materialModel,
  395. materialCode: e.materialCode,
  396. orderPlanWeight: null,
  397. meterNumber: e.materialName.replace(/[^0-9]/gi, ""),
  398. isPound: getisPound,
  399. //物资Id
  400. materialId: e.materialId
  401. //有米数
  402. };
  403. console.log(addmap);
  404. } else {
  405. var addmap = {
  406. capacityNumber: this.capacityNumber,
  407. orderId: this.orderId,
  408. materialName: e.materialName,
  409. Specification: e.materialSpecification + e.materialModel,
  410. materialCode: e.materialCode,
  411. orderPlanWeight: null,
  412. meterNumber: null,
  413. isPound: getisPound,
  414. //物资Id
  415. materialId: e.materialId
  416. };
  417. }
  418. }
  419. this.materialList.push(addmap);
  420. this.materialList.forEach(e => {
  421. this.$set(e, "capacityNumber", this.capacityNumber);
  422. });
  423. this.getSpanArr1(this.materialList);
  424. console.log(this.materialList);
  425. });
  426. this.materialList1 = [];
  427. this.table1 = false;
  428. },
  429. rowDbClick(row) {
  430. this.materialList1 = [];
  431. this.materialList1.push(row);
  432. this.makeSureMaterial();
  433. },
  434. openDrawer() {
  435. this.table1 = true;
  436. },
  437. //返回选中的物资信息
  438. selectionChange(selection) {
  439. this.materialList1 = [];
  440. this.materialList1 = selection;
  441. },
  442. //物资模态框查询
  443. onclick() {
  444. this.option.requestUrl =
  445. "/api/v1/uc/getSteelMaterial?apiId=244&materialNameText=" +
  446. this.materialNameText +
  447. "&materialSpecificationText=" +
  448. this.materialSpecificationText;
  449. },
  450. //开关是否删除
  451. showDelete() {
  452. this.isDelete = true;
  453. },
  454. deleteMaterialRow(index, rows) {
  455. rows.splice(index, 1);
  456. this.status = 1;
  457. },
  458. updateMaterial(scope) {
  459. this.materialList = this.tableData.filter((item, index) => {
  460. return item.orderId == scope.row.orderId;
  461. });
  462. this.materialList.forEach(e => {
  463. this.capacityNumber = e.capacityNumber;
  464. this.orderId = e.orderId;
  465. });
  466. this.getSpanArr1(this.materialList);
  467. this.title = "处理" + "-" + this.capacityNumber + "-" + "异常物资信息";
  468. this.dialogTableVisible = true;
  469. },
  470. getOrderList() {
  471. this.axios
  472. .post(
  473. "/api/v1/oms/getDriverInfoForSale1?saleOrderId=" +
  474. this.$route.params.saleOrderId +
  475. "&i=" +
  476. new Date()
  477. )
  478. .then(res => {
  479. this.tableData = res.data.data;
  480. this.getSpanArr(this.tableData);
  481. });
  482. },
  483. onclick() {},
  484. back() {
  485. this.$router.push("/saleOrderSteel");
  486. },
  487. getSpanArr1(data) {
  488. //每次调用方法初始化
  489. this.spanArr1 = [];
  490. for (var i = 0; i < data.length; i++) {
  491. if (i === 0) {
  492. this.spanArr1.push(1);
  493. this.pos1 = 0;
  494. } else {
  495. // 判断当前元素与上一个元素是否相同
  496. if (data[i].capacityNumber === data[i - 1].capacityNumber) {
  497. this.spanArr1[this.pos1] += 1;
  498. this.spanArr1.push(0);
  499. } else {
  500. this.spanArr1.push(1);
  501. this.pos1 = i;
  502. }
  503. }
  504. }
  505. },
  506. objectSpanMethod1({ row, column, rowIndex, columnIndex }) {
  507. if (columnIndex === 0) {
  508. const _row = this.spanArr1[rowIndex];
  509. const _col = _row > 0 ? 1 : 0;
  510. return {
  511. rowspan: _row,
  512. colspan: _col
  513. };
  514. }
  515. },
  516. //记录每一行的合并数
  517. getSpanArr(data) {
  518. //每次调用方法初始化
  519. this.spanArr = [];
  520. for (var i = 0; i < data.length; i++) {
  521. if (i === 0) {
  522. this.spanArr.push(1);
  523. this.pos = 0;
  524. data[i].group = i;
  525. } else {
  526. // 判断当前元素与上一个元素是否相同
  527. if (data[i].orderId === data[i - 1].orderId) {
  528. this.spanArr[this.pos] += 1;
  529. this.spanArr.push(0);
  530. data[i].group = data[i - 1].group;
  531. } else {
  532. this.spanArr.push(1);
  533. this.pos = i;
  534. data[i].group = data[i - 1].group + 1;
  535. }
  536. }
  537. }
  538. },
  539. objectSpanMethod({ row, column, rowIndex, columnIndex }) {
  540. if (
  541. columnIndex === 0 ||
  542. columnIndex === 1 ||
  543. columnIndex === 2 ||
  544. columnIndex === 3 ||
  545. columnIndex === 4 ||
  546. columnIndex === 8
  547. ) {
  548. const _row = this.spanArr[rowIndex];
  549. const _col = _row > 0 ? 1 : 0;
  550. return {
  551. rowspan: _row,
  552. colspan: _col
  553. };
  554. }
  555. }
  556. }
  557. };
  558. </script>
  559. <style lang="scss" scoped>
  560. .updateSteelDetails {
  561. .top {
  562. margin-top: 20px;
  563. margin-left: 20px;
  564. .el-input {
  565. width: 250px;
  566. }
  567. }
  568. .table {
  569. margin-top: 20px;
  570. margin-left: 20px;
  571. }
  572. .dialog {
  573. width: 600px;
  574. .buttonx {
  575. display: flex;
  576. justify-content: center;
  577. align-items: center;
  578. }
  579. }
  580. }
  581. </style>