updateTransPrice.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. <template>
  2. <!-- 修改运价 -->
  3. <div id="contractDetails">
  4. <page-title>编辑</page-title>
  5. <div class="form">
  6. <div class="form_box">
  7. <el-form :model="obj" :rules="batchFormRules" label-width="100px" label-position="left">
  8. <div class="preview-group">
  9. <el-form-item label="运价" prop="priceValue">
  10. <el-input v-model="obj.priceValue" placeholder="请输入内容" type="number"></el-input>
  11. </el-form-item>
  12. <el-form-item label="物资" prop="materialNames">
  13. <el-input v-model="obj.materialNames" readonly></el-input>
  14. <el-button type="primary" class="btnml" @click="materialDrawer"
  15. >浏览物资</el-button>
  16. </el-form-item>
  17. <el-form-item label="执行日期" prop="priceDate">
  18. <el-date-picker
  19. v-model="obj.priceDate"
  20. type="date"
  21. placeholder="选择日期">
  22. </el-date-picker>
  23. </el-form-item>
  24. <el-form-item label="联动公式" prop="oilPriceFormula">
  25. <el-input v-model="obj.oilPriceFormula" placeholder="请选择油价联动公式" readonly disabled></el-input>
  26. <el-button type="primary" class="btn" @click="oilPriceFormulaClick"
  27. >浏览</el-button>
  28. </el-form-item>
  29. <el-form-item label="运力类型" prop="capacityTypeName">
  30. <el-input v-model="obj.capacityTypeName" readonly></el-input>
  31. </el-form-item>
  32. <el-form-item label="当前基准油价" prop="oilpriceBase">
  33. <el-input v-model="obj.oilpriceBase"></el-input>
  34. </el-form-item>
  35. <el-form-item label="油品名称" prop="oilTypeName">
  36. <el-input v-model="obj.oilTypeName" readonly></el-input>
  37. </el-form-item>
  38. <el-form-item label="油价变化率阈值" prop="oilpriceChangeThreshold">
  39. <el-input v-model="obj.oilpriceChangeThreshold" readonly></el-input>
  40. </el-form-item>
  41. <el-form-item label="计价单位" prop="type">
  42. <el-input v-model="obj.type" readonly></el-input>
  43. </el-form-item>
  44. </div>
  45. </el-form>
  46. </div>
  47. </div>
  48. <!-- 物资表格 -->
  49. <div class="selectionTable from">
  50. <el-table
  51. :data="selectionList"
  52. border
  53. style="width: 100%"
  54. highlight-current-row
  55. >
  56. <el-table-column type="index" label="序号" width="50">
  57. </el-table-column>
  58. <el-table-column
  59. v-for="(item, i) in tableTop"
  60. :key="i"
  61. :prop="item.prop"
  62. :label="item.label"
  63. :width="item.width"
  64. align="center"
  65. show-overflow-tooltip
  66. >
  67. </el-table-column>
  68. <!-- 操作列 -->
  69. <el-table-column fixed="right" label="操作" width="100">
  70. <template slot-scope="scope">
  71. <el-button
  72. @click="deleteRow(scope.$index)"
  73. type="text"
  74. icon="el-icon-close"
  75. size="big"
  76. ></el-button>
  77. </template>
  78. </el-table-column>
  79. </el-table>
  80. </div>
  81. <!-- 油价联动公式模态框 -->
  82. <el-drawer
  83. title="请选择油价联动公式"
  84. :visible.sync="oilPriceFormulaDrawer"
  85. :direction="direction"
  86. :before-close="handleClose"
  87. close-on-press-escape
  88. modal
  89. wrapperClosable
  90. size="40%"
  91. >
  92. <div class="selectText">
  93. <!-- <span></span> -->
  94. <el-input v-model="LineText" placeholder="请输入内容"></el-input>
  95. <el-button
  96. type="primary"
  97. @click="selectLineClick"
  98. :loading="selectLineLoading"
  99. ><i class="el-icon-search"></i>查询</el-button
  100. >
  101. <el-button type="primary" @click="addoilPriceFormula">确定</el-button>
  102. </div>
  103. <div class="LineTable">
  104. <vue-scroll :ops="ops" style="width:100%;height:100%">
  105. <dilTable
  106. v-bind.sync="oilPriceFormula"
  107. @radio-change="currentRadioChange"
  108. :isKuang="isKuang"
  109. :loading="tableLoading"
  110. :drawer="oilPriceFormulaDrawer"
  111. @func="func"
  112. ></dilTable>
  113. </vue-scroll>
  114. </div>
  115. </el-drawer>
  116. <!-- 物资模态框 -->
  117. <el-drawer
  118. title="请选择物资"
  119. :visible.sync="drawerMaterial"
  120. :direction="direction"
  121. close-on-press-escape
  122. modal
  123. wrapperClosable
  124. size="40%"
  125. >
  126. <div class="selectText">
  127. <el-input v-model="materialText" placeholder="请输入内容"></el-input>
  128. <el-button
  129. type="primary"
  130. @click="selectMaterial"
  131. :loading="selectLineLoading"
  132. ><i class="el-icon-search"></i>查询</el-button
  133. >
  134. <el-button type="primary" @click="addMaterialList">确定</el-button>
  135. </div>
  136. <div class="LineTable">
  137. <vue-scroll :ops="ops" style="width:100%;height:100%">
  138. <dilTable
  139. v-bind.sync="materialOptions"
  140. @selection-change="selectionChange"
  141. :isKuang="isKuang"
  142. :loading="tableLoading"
  143. :drawer="oilPriceFormulaDrawer"
  144. @func="func"
  145. ></dilTable>
  146. </vue-scroll>
  147. </div>
  148. </el-drawer>
  149. <div class="button_box">
  150. <el-button type="primary" @click="onClickConfirm">修改</el-button>
  151. <el-button @click="onClickCancel">返回</el-button>
  152. </div>
  153. </div>
  154. </template>
  155. <script>
  156. import { sjTime, isNumber } from "@/utils/sharedJsFile";
  157. export default {
  158. name: "updateTransPrice",
  159. data() {
  160. return {
  161. //公式内容
  162. formulaString: null,
  163. oilPriceFormulaId: null,
  164. rangeId: null,
  165. options: [],
  166. //油价联动公式模态窗口的数据
  167. oilPriceFormula: {
  168. requestUrl: "",
  169. selectionType: "radio"
  170. },
  171. newsArr: [],
  172. selectionList: [],
  173. //是否打开油价联动公式的模态窗口
  174. oilPriceFormulaDrawer: false,
  175. //油价联动公式查询条件
  176. LineText: null,
  177. //是否点击查询
  178. isKuang: false,
  179. //表格加载状态
  180. tableLoading: false,
  181. //物资模态框默认隐藏
  182. drawerMaterial: false,
  183. //模态窗口的打开的方向
  184. direction: "rtl",
  185. //物资查询框
  186. materialText: null,
  187. //油价联动公式模态框查询按钮状态
  188. selectLineLoading: false,
  189. obj: {},
  190. //表单数据
  191. form1: {
  192. priceDate: new Date(),
  193. oilTypeId: 10,
  194. capacityTypeId: 1
  195. },
  196. batchFormRules: {
  197. priceValue: [{ required: true, message: '运价不能为空', trigger: 'blur' }],
  198. priceDate: [{ required: true, message: '执行日期不能为空', trigger: 'blur' }],
  199. oilpriceBase: [{ required: true, message: '油价基准不能为空', trigger: 'blur' }]
  200. },
  201. tableTop: [
  202. {
  203. prop: "materialName",
  204. label: "物资名称"
  205. }
  206. ],
  207. ops: {
  208. vuescroll: {},
  209. scrollPanel: {},
  210. rail: {
  211. keepShow: true
  212. },
  213. bar: {
  214. hoverStyle: true,
  215. onlyShowBarOnScroll: false, //是否只有滚动的时候才显示滚动条
  216. background: "#5f9ea0", //滚动条颜色
  217. opacity: 0.8, //滚动条透明度
  218. "overflow-x": "hidden"
  219. }
  220. },
  221. materialOptions: {
  222. requestUrl: "",
  223. selectionType: "select"
  224. }
  225. };
  226. },
  227. mounted() {
  228. this.axios.get("/api/v1/uc/getTransRange").then(res => {
  229. this.options = res.data.data;
  230. });
  231. this.obj=this.$route.query.row;
  232. this.axios.post("/api/v1/ams/getwz",{"priceId":this.obj.priceId}).then(res => {
  233. this.selectionList = res.data.data;
  234. });
  235. //根据price_id查询联动公式和列表传过去
  236. this.axios.post("/api/v1/ams/getcargonameId",{"priceId":this.obj.priceId}).then(res => {
  237. this.obj.oilPriceFormula = res.data.data.formulaString,
  238. this.obj.cargonameId = res.data.data.formulaId;
  239. this.oilPriceFormulaId=this.obj.cargonameId;
  240. });
  241. this.rangeId=this.obj.rangeId
  242. },
  243. methods: {
  244. //打开线路的模态窗口
  245. oilPriceFormulaClick() {
  246. this.oilPriceFormulaDrawer = true;
  247. this.oilPriceFormula.requestUrl = "/api/v1/uc/getOilFormula?apiId=444";
  248. },
  249. currentRadioChange(val) {
  250. this.formulaString = val.formulaString;
  251. this.oilPriceFormulaId = val.formulaId;
  252. },
  253. //选定联动公式确定
  254. addoilPriceFormula() {
  255. this.obj.oilPriceFormula=this.formulaString,
  256. this.obj.cargonameId = this.oilPriceFormulaId;
  257. this.obj.capacityTypeId = this.form1.capacityTypeId;
  258. this.obj.oilTypeId=this.form1.oilTypeId
  259. this.oilPriceFormulaDrawer = false;
  260. },
  261. selectLineClick() {
  262. this.tableLoading = true;
  263. this.selectLineLoading = true;
  264. this.isKuang = true;
  265. if (this.LineText) {
  266. this.oilPriceFormula.requestUrl =
  267. "api/v1/uc/getOilFormula?apiId=444&con=" + this.LineText;
  268. } else {
  269. this.oilPriceFormula.requestUrl =
  270. "api/v1/uc/getOilFormula?apiId=444&i=" + new Date();
  271. }
  272. },
  273. //模态窗口关闭时调用
  274. handleClose() {
  275. if (this.oilPriceFormulaDrawer) {
  276. this.oilPriceFormulaDrawer = false;
  277. this.LineText = null;
  278. }
  279. },
  280. //点击删除按钮删除当前点击的对象
  281. deleteRow(index) {
  282. this.selectionList.splice(index, 1);
  283. },
  284. func(res) {
  285. this.selectLineLoading = false;
  286. this.isKuang = false;
  287. this.tableLoading = false;
  288. },
  289. selectionChange(selection) {
  290. console.log(selection);
  291. for (let i = 0; i < selection.length; i++) {
  292. if (this.newsArr.indexOf(selection[i]) === -1) {
  293. this.newsArr.push(selection[i]);
  294. }
  295. }
  296. },
  297. addMaterialList() {
  298. this.drawerMaterial = false;
  299. this.newsArr.forEach(e => {
  300. console.log(e.materialName);
  301. var addmap = {
  302. materialName: e.materialTypeName,
  303. materialId: e.materialTypeId
  304. };
  305. this.selectionList.push(addmap);
  306. });
  307. console.log(this.selectionList);
  308. this.newsArr = [];
  309. },
  310. selectMaterial() {
  311. if (this.materialText == null) {
  312. this.materialOptions.requestUrl =
  313. "/api/v1/uc/queryMaterialByLike?apiId=244&i=" + new Date();
  314. } else {
  315. this.materialOptions.requestUrl =
  316. "/api/v1/rms/getInwardContractMaterial?apiId=482&con=" +
  317. this.materialText;
  318. }
  319. },
  320. materialDrawer() {
  321. this.drawerMaterial = true;
  322. this.materialOptions.requestUrl =
  323. "/api/v1/rms/getInwardContractMaterial?apiId=482&i=" + new Date();
  324. },
  325. // 返回
  326. onClickCancel() {
  327. this.$router.go(-1);
  328. },
  329. // 修改
  330. onClickConfirm() {
  331. if (this.obj.priceValue==''|| this.obj.priceValue == undefined){
  332. this.$message.info("修改前请填写运价!")
  333. return;
  334. }
  335. let mapValue = {
  336. cargonameId: this.oilPriceFormulaId,
  337. capacityTypeId: this.obj.capacityTypeId,
  338. priceValue: this.obj.priceValue,
  339. priceDate: sjTime(this.obj.priceDate),
  340. type: this.obj.type,
  341. oilpriceBase: this.obj.oilpriceBase,
  342. oilTypeId: this.obj.oilTypeId,
  343. oilpriceChangeThreshold: this.obj.oilpriceChangeThreshold,
  344. rangeId: this.rangeId,
  345. mapList: this.selectionList,
  346. priceId: this.obj.priceId
  347. };
  348. this.axios
  349. .post(
  350. "/api/v1/ams/updateTransPrice",
  351. mapValue
  352. )
  353. .then((res) => {
  354. if (res.data.data >=1) {
  355. this.$message.success("修改成功!")
  356. this.$router.go(-1);
  357. }
  358. });
  359. }
  360. }
  361. }
  362. </script>
  363. <style lang="scss" scoped>
  364. .form {
  365. display: flex;
  366. .form_box {
  367. width: 500px;
  368. margin-left: 35%;
  369. margin-top: 30px;
  370. margin-right: 20px;
  371. .el-form {
  372. .preview-group {
  373. .el-form-item {
  374. .el-form-item__label {
  375. display: inline-block;
  376. width: 70px !important;
  377. }
  378. .el-form-item__content {
  379. .el-select {
  380. width: 250px;
  381. }
  382. .el-input {
  383. width: 250px;
  384. }
  385. }
  386. }
  387. }
  388. }
  389. };
  390. .txt1{
  391. display: inline-block;
  392. width: 150px;
  393. text-align: right;
  394. };
  395. }
  396. .elForm {
  397. margin-left: 30%;
  398. }
  399. .button_box {
  400. margin-left: 45%;
  401. }
  402. </style>