OpTicketBlackCode.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  1. <template>
  2. <div class="car_add">
  3. <div>
  4. <div class="communal-title">
  5. <div>{{ title }}</div>
  6. </div>
  7. </div>
  8. <div style="display: flex;">
  9. <div style="text-align:left;font-size: 17px;font-weight: 600;color: #555;">
  10. 团组成本预算 - 机票的预算:
  11. </div>
  12. <div style="margin-left:20px;color: #555;" v-if="airGroupCostParameter != null">
  13. 经济舱: {{ airGroupCostParameter.jjccb }}元/人 {{ airGroupCostParameter.jjcrs }}人
  14. 共:{{ airGroupCostParameter.jjccb * airGroupCostParameter.jjcrs
  15. }}元&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  16. 公务舱: {{ airGroupCostParameter.gwccb }}元/人 {{ airGroupCostParameter.gwcrs }}人
  17. 共:{{ airGroupCostParameter.gwccb * airGroupCostParameter.gwcrs
  18. }}元&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  19. </div>
  20. <div style="margin-left:20px;" v-else>
  21. 团组成本暂未开放此团数据!
  22. </div>
  23. </div>
  24. <hr style='background-color:#5555; height:1px; border:none;margin: 10px 0;' />
  25. <div>
  26. <el-form :model="delegationInfo" label-width="100px" class="demo-ruleForm">
  27. <div style="display: flex;">
  28. <div style="width: 25%;">
  29. <el-form-item label="团组名称:" label-width="160px">
  30. <el-select v-model="DiId" clearable filterable placeholder="团组选择"
  31. @change="AirTicketResChange" :disabled="isShow" style="width: 100%;">
  32. <el-option v-for="item in DelegationSelect" :key="item.id" :label="item.groupName"
  33. :value="item.id">
  34. </el-option>
  35. </el-select>
  36. </el-form-item>
  37. </div>
  38. <div style="width: 25%;">
  39. <el-form-item label="团 号:" prop="tourCode" label-width="160px">
  40. <el-input placeholder="团号" v-model="delegationInfo.tourCode" :disabled="true">
  41. </el-input>
  42. </el-form-item>
  43. </div>
  44. <div style="width: 25%;">
  45. <el-form-item label="客户:" prop="clientName" label-width="160px">
  46. <el-input placeholder="客户" v-model="delegationInfo.clientName" :disabled="true">
  47. </el-input>
  48. </el-form-item>
  49. </div>
  50. <div style="width: 25%;">
  51. <el-form-item label="出访国家:" prop="visitCountry" label-width="160px">
  52. <el-input placeholder="出访国家" v-model="delegationInfo.visitCountry" :disabled="true">
  53. </el-input>
  54. </el-form-item>
  55. </div>
  56. </div>
  57. </el-form>
  58. <el-form :model="OpTicketBlackCodeData" :rules="OpTicketBlackCodeRules" ref="OpTicketBlackCodeData"
  59. label-width="100px" class="demo-ruleForm">
  60. <div>
  61. <el-form-item label="标题:" prop="title" label-width="160px">
  62. <el-input placeholder="标题" v-model="OpTicketBlackCodeData.title">
  63. </el-input>
  64. </el-form-item>
  65. </div>
  66. <div>
  67. <span style="color: red; padding-left: 100px;">
  68. 请严格遵守此格式!!! 1.KL1723 SU06DEC AMSBRU 0925 1010 -- -- ERJ190 45M (是中转情况下末尾添加[中转])
  69. </span>
  70. </div>
  71. <div style="display: flex;">
  72. <div style="width: 60%;">
  73. <el-form-item label="黑屏代码:" prop="blackCode" label-width="160px">
  74. <!-- @input="parseAirData" -->
  75. <el-input type="textarea" :rows="14"
  76. placeholder="请严格遵守此格式!!! 1. EK363 R1 WE08MAR CANDXB HK7 0015 0515 SEAME 2 3 (注意空格以及多条数据换行)"
  77. v-model="OpTicketBlackCodeData.blackCode"></el-input>
  78. </el-form-item>
  79. </div>
  80. <div style="width: 40%;">
  81. <el-form-item label="经济舱现价:" label-width="160px">
  82. <!-- <el-input type="textarea" :rows="3" placeholder="现价说明"
  83. v-model="OpTicketBlackCodeData.nowPrice"></el-input> -->
  84. <el-input placeholder="经济舱现价" v-model="OpTicketBlackCodeData.price">
  85. </el-input>
  86. </el-form-item>
  87. <el-form-item label="经济舱全价:" label-width="160px">
  88. <el-input placeholder="经济舱全价" v-model="OpTicketBlackCodeData.ecPrice">
  89. </el-input>
  90. </el-form-item>
  91. <el-form-item label="公务舱现价:" label-width="160px">
  92. <el-input placeholder="公务舱现价" v-model="OpTicketBlackCodeData.nowPrice">
  93. </el-input>
  94. <!-- <el-input type="textarea" :rows="3" placeholder="全价说明"
  95. v-model="OpTicketBlackCodeData.price"></el-input> -->
  96. </el-form-item>
  97. <el-form-item label="公务舱全价:" label-width="160px">
  98. <el-input placeholder="公务舱全价" v-model="OpTicketBlackCodeData.bcPrice">
  99. </el-input>
  100. </el-form-item>
  101. <el-form-item label="头等舱现价:" label-width="160px">
  102. <el-input placeholder="头等舱现价" v-model="OpTicketBlackCodeData.fcNowPrice">
  103. </el-input>
  104. </el-form-item>
  105. <el-form-item label="头等舱全价:" label-width="160px">
  106. <el-input placeholder="头等舱全价" v-model="OpTicketBlackCodeData.fcPrice">
  107. </el-input>
  108. </el-form-item>
  109. </div>
  110. </div>
  111. <div style="display: flex;">
  112. <div style="width: 60%;">
  113. <el-form-item label="备注:" prop="remark" label-width="160px">
  114. <el-input type="textarea" :rows="3" placeholder="备注"
  115. v-model="OpTicketBlackCodeData.remark"></el-input>
  116. </el-form-item>
  117. </div>
  118. <div style="width: 40%;text-align:right;margin-top: 2%;">
  119. <div>
  120. <el-button type="primary" @click="addBtn">保存</el-button>
  121. <el-button @click="back()">取消</el-button>
  122. </div>
  123. </div>
  124. </div>
  125. </el-form>
  126. </div>
  127. <!-- <div id="testTable">
  128. <el-table border :data="tableData" style="width: 100%">
  129. <el-table-column v-for="column in columns" :key="column.prop" :prop="column.prop" :label="column.label"
  130. :width="column.width">
  131. <template slot-scope="scope">
  132. <el-input v-model="scope.row[column.prop]" :disabled="column.prop === 'id'"></el-input>
  133. </template>
  134. </el-table-column>
  135. </el-table>
  136. </div> -->
  137. </div>
  138. </template>
  139. <script>
  140. export default {
  141. data() {
  142. return {
  143. title: "新增机票行程代码录入",
  144. token: '',
  145. userId: 0,
  146. id: '',
  147. DiId: '',
  148. isShow: false,
  149. delegationInfo: {},
  150. DelegationSelect: [],//团组下拉框
  151. airGroupCostParameter: {},//机票成本预算
  152. OpTicketBlackCodeData: {
  153. status: 0,
  154. id: 0,
  155. diId: 0,
  156. blackCode: '',
  157. price: '',
  158. nowPrice: '',
  159. bcPrice: '',
  160. ecPrice: '',
  161. createUserId: 0,
  162. remark: '',
  163. title: '',
  164. //头等舱字段
  165. fcNowPrice: 0,
  166. fcPrice: 0
  167. },
  168. OpTicketBlackCodeRules: {
  169. blackCode: [
  170. { required: true, message: '该信息为必填信息', trigger: ['blur', 'change'] },
  171. ],
  172. price: [
  173. { required: true, message: '该信息为必填信息', trigger: ['blur', 'change'] },
  174. ],
  175. nowPrice: [
  176. { required: true, message: '该信息为必填信息', trigger: ['blur', 'change'] },
  177. ],
  178. bcPrice: [
  179. { required: true, message: '请输入机票单价', trigger: ['blur', 'change'] },
  180. { pattern: /^(([1-9]?\d{0,8}(\.\d{1,2})?)|999999999|999999999\.(0){1,2})$/, message: '请输入正确的金额(最多2位小数)' }
  181. ],
  182. ecPrice: [
  183. { required: true, message: '请输入机票单价', trigger: ['blur', 'change'] },
  184. { pattern: /^(([1-9]?\d{0,8}(\.\d{1,2})?)|999999999|999999999\.(0){1,2})$/, message: '请输入正确的金额(最多2位小数)' }
  185. ],
  186. title: [
  187. { required: true, message: '该信息为必填信息', trigger: ['blur', 'change'] },
  188. ],
  189. },
  190. //-------------------------
  191. flightData: [
  192. {
  193. type: "经济现价",
  194. prices: {
  195. },
  196. total: 0
  197. },
  198. {
  199. type: "经济全价",
  200. prices: {
  201. },
  202. total: 0
  203. },
  204. {
  205. type: "公务现价",
  206. prices: {
  207. },
  208. total: 0
  209. },
  210. {
  211. type: "公务全价",
  212. prices: {
  213. },
  214. total: 0
  215. },
  216. {
  217. type: "头等现价",
  218. prices: {
  219. },
  220. total: 0
  221. },
  222. {
  223. type: "头等全价",
  224. prices: {
  225. },
  226. total: 0
  227. }
  228. ],
  229. tableData: [],
  230. columns: [
  231. ],
  232. PushColumns: [],
  233. fiexedColumns: [{ prop: 'type', label: '票价类型', width: 180 },
  234. { prop: 'total', label: '合计', width: 180 }],
  235. settingValue: {
  236. "经济现价": "price",
  237. "经济全价": "ecPrice",
  238. "公务现价": "nowPrice",
  239. "公务全价": "bcPrice",
  240. "头等现价": "fcNowPrice",
  241. "头等全价": "fcPrice"
  242. }
  243. }
  244. },
  245. methods: {
  246. //团组下拉框
  247. DelegationSelectFun() {
  248. var url = "/api/Business/GetGroupNameList"
  249. var that = this
  250. this.$axios({
  251. method: 'post',
  252. url: url,
  253. headers: {
  254. Authorization: 'Bearer ' + this.token
  255. },
  256. data: {
  257. "portType": 1,
  258. "pageIndex": 0,
  259. "pageSize": 0
  260. }
  261. }).then(function (res) {
  262. if (res.data.code == 200) {
  263. that.DelegationSelect = res.data.data;
  264. }
  265. })
  266. },
  267. QueryTicketBlackCodeById() {
  268. var url = "/api/Resource/QueryTicketBlackCodeById"
  269. var that = this
  270. this.$axios({
  271. method: 'post',
  272. url: url,
  273. headers: {
  274. Authorization: 'Bearer ' + this.token
  275. },
  276. data: {
  277. Id: that.id,
  278. DiId: that.DiId
  279. }
  280. }).then(function (res) {
  281. if (res.data.code == 200) {
  282. that.delegationInfo = res.data.data.delegationInfo;
  283. that.airGroupCostParameter = res.data.data.groupCostParameter;
  284. if (res.data.data.ticketBlackCode) {
  285. var TicketBlackCode = res.data.data.ticketBlackCode;
  286. that.OpTicketBlackCodeData.id = TicketBlackCode.id
  287. that.OpTicketBlackCodeData.diId = TicketBlackCode.diId
  288. that.OpTicketBlackCodeData.blackCode = TicketBlackCode.blackCode
  289. that.OpTicketBlackCodeData.price = TicketBlackCode.price
  290. that.OpTicketBlackCodeData.nowPrice = TicketBlackCode.nowPrice
  291. that.OpTicketBlackCodeData.bcPrice = TicketBlackCode.bcPrice
  292. that.OpTicketBlackCodeData.ecPrice = TicketBlackCode.ecPrice
  293. that.OpTicketBlackCodeData.remark = TicketBlackCode.remark
  294. that.OpTicketBlackCodeData.title = TicketBlackCode.title;
  295. that.OpTicketBlackCodeData.fcNowPrice = TicketBlackCode.fcNowPrice;
  296. that.OpTicketBlackCodeData.fcPrice = TicketBlackCode.fcPrice;
  297. // for (var key in that.settingValue) {
  298. // that.flightData.filter(item => item.type == key)[0].total = TicketBlackCode[that.settingValue[key]];
  299. // }
  300. }
  301. }
  302. //that.parseAirData();
  303. })
  304. },
  305. //跳转
  306. back() {
  307. this.$router.push({
  308. path: "/home/TicketBlackCode",
  309. query: {
  310. DiId: this.DiId,
  311. }
  312. })
  313. },
  314. //团组下拉框选择事件
  315. AirTicketResChange() {
  316. this.QueryTicketBlackCodeById()
  317. },
  318. //点击保存事件
  319. addBtn() {
  320. if (!this.DiId) {
  321. this.$message.error("请选择团组名称");
  322. return;
  323. }
  324. const that = this;
  325. that.$refs.OpTicketBlackCodeData.validate((valid) => {
  326. if (valid) {
  327. //that.parseAirData();
  328. var url = "/api/Resource/OpTicketBlackCode"
  329. that.OpTicketBlackCodeData.createUserId = that.userId;
  330. that.OpTicketBlackCodeData.diId = that.DiId
  331. that.OpTicketBlackCodeData.price = that.OpTicketBlackCodeData.price.toString();
  332. that.OpTicketBlackCodeData.nowPrice = that.OpTicketBlackCodeData.nowPrice.toString();
  333. that.$axios({
  334. method: 'post',
  335. url: url,
  336. headers: {
  337. Authorization: 'Bearer ' + that.token
  338. },
  339. data: that.OpTicketBlackCodeData
  340. }).then(function (res) {
  341. if (res.data.code == 200) {
  342. that.$message({
  343. message: res.data.msg,
  344. type: 'success'
  345. });
  346. setTimeout(() => {
  347. that.back();
  348. // that.$router.push('/home/TicketBlackCode')
  349. }, 1000);
  350. } else {
  351. that.$message.error(res.data.msg);
  352. }
  353. })
  354. } else {
  355. this.$message.error('请完善信息在保存!');
  356. return false;
  357. }
  358. })
  359. },
  360. parseAirData() {
  361. var data = this.OpTicketBlackCodeData.blackCode;
  362. // 按行分割数据
  363. const lines = data.trim().split('\n');
  364. // 提取航司的函数
  365. function extractAirline(line) {
  366. // 使用正则表达式匹配航司代码(两个大写字母或一个大写字母加一个数字)
  367. const match = line.match(/[A-Z]{2}|[A-Z]\d/);
  368. return match ? match[0] : null;
  369. }
  370. // 解析每一行并提取航司
  371. var flightNumbers = lines.map(line => {
  372. // 使用正则表达式匹配航班号(假设航班号是字母+数字的组合)
  373. const match = line.match(/[A-Z]{2}\d+/);
  374. console.log(match, "match ");
  375. return match ? match[0] : null;
  376. });
  377. flightNumbers = flightNumbers.filter(item => item);
  378. //console.log(flightNumbers, "flightNumbers ");
  379. this.PushColumns = flightNumbers.map(flightNumber => {
  380. return {
  381. prop: flightNumber,
  382. label: flightNumber,
  383. width: 100
  384. }
  385. })
  386. // {
  387. // type: "公务全价",
  388. // prices: {
  389. // FM: 55320,
  390. // EK: 22883,
  391. // "3U": 33608
  392. // },
  393. // total: 111811
  394. // }
  395. var that = this;
  396. //console.log(this.tableData, "this.tableData ");
  397. this.tableData.forEach(item => {
  398. that.flightData.forEach(flight => {
  399. if (flight.type == item.type) {
  400. var columns = that.PushColumns.map(x => x.prop);
  401. for (var i = 0; i < columns.length; i++) {
  402. flight.prices[columns[i]] = item[columns[i]];
  403. }
  404. }
  405. })
  406. for (var key in that.settingValue) {
  407. if (item.type == key) {
  408. that.OpTicketBlackCodeData[that.settingValue[key]] = Number(item.total);
  409. break;
  410. }
  411. }
  412. })
  413. this.flightData.forEach(item => {
  414. //遍历item.prices
  415. for (var key in item.prices) {
  416. //判断key是否存在that.PushColumns中
  417. var isExist = false;
  418. for (var i = 0; i < that.PushColumns.length; i++) {
  419. if (that.PushColumns[i].prop == key) {
  420. isExist = true;
  421. break;
  422. }
  423. }
  424. //不存在就删除item.prices中的key
  425. if (!isExist) {
  426. delete item.prices[key];
  427. }
  428. }
  429. that.PushColumns.forEach(column => {
  430. //判断item.prices中是否存在column.prop
  431. if (item.prices[column.prop]) {
  432. return;
  433. } else {
  434. item.prices[column.prop] = 0;
  435. }
  436. })
  437. })
  438. console.log(this.flightData, "this.flightData ");
  439. console.log(this.columns, "this.columns ");
  440. this.transformData();
  441. },
  442. //----------------------
  443. transformData() {
  444. this.columns = [];
  445. this.columns.push(...this.fiexedColumns);
  446. this.columns.splice(1, 0, ...this.PushColumns);
  447. this.tableData = [];
  448. this.tableData = this.flightData.map(item => {
  449. const tableItem = { type: item.type, total: item.total };
  450. for (let column of this.columns) {
  451. if (column.prop !== 'type' && column.prop !== 'total') {
  452. tableItem[column.prop] = item.prices[column.prop];
  453. }
  454. }
  455. return tableItem;
  456. });
  457. },
  458. },
  459. mounted() {
  460. this.token = JSON.parse(localStorage.getItem('userinif')).token;
  461. this.userId = JSON.parse(localStorage.getItem('userinif')).userInfo.userId
  462. this.id = this.$route.query.id
  463. this.DiId = parseInt(this.$route.query.DiId)
  464. this.DelegationSelectFun()
  465. var that = this
  466. if (that.DiId && that.id) {
  467. that.OpTicketBlackCodeData.status = 2;
  468. that.isShow = true
  469. } else {
  470. that.isShow = false
  471. that.OpTicketBlackCodeData.status = 1;
  472. }
  473. that.QueryTicketBlackCodeById();
  474. //-------
  475. //this.transformData();
  476. }
  477. }
  478. </script>
  479. <style>
  480. .communal-list {
  481. background-color: #fff;
  482. padding: 10px;
  483. box-shadow: 0 0 5px #0005;
  484. border-radius: 10px;
  485. }
  486. .car_add .communal-title {
  487. display: flex;
  488. font-size: 17px;
  489. font-weight: 600;
  490. color: #555;
  491. margin-bottom: 20px;
  492. justify-content: space-between;
  493. align-items: center;
  494. }
  495. .appraise-box {
  496. display: flex;
  497. flex-wrap: wrap;
  498. justify-content: space-between;
  499. margin: 50px 0;
  500. }
  501. .appraise-box>div {
  502. width: 30%;
  503. }
  504. .communal-box {
  505. display: flex;
  506. }
  507. .communal-box>button {
  508. margin-left: 10px;
  509. padding: 8px 20px;
  510. }
  511. .car_add {
  512. background-color: #fff;
  513. padding: 20px;
  514. box-shadow: 0 0 5px #0005;
  515. border-radius: 10px;
  516. }
  517. @media screen and (max-width: 1700px) {
  518. .appraise-box>div {
  519. width: 48%;
  520. }
  521. .appraise-box>div el-form-item__content {
  522. width: 260px !important;
  523. }
  524. }
  525. </style>