tb-car-disincle-edit.html 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>入境登记-添加/修改</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  6. <meta name="viewport"
  7. content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  8. <!-- 所有的 css js 资源 -->
  9. <link rel="stylesheet" href="../../static/kj/element-ui/theme-chalk/index.css">
  10. <link rel="stylesheet" href="../../static/sa.css">
  11. <script src="../../static/kj/vue.min.js"></script>
  12. <script src="../../static/kj/element-ui/index.js"></script>
  13. <script src="../../static/kj/httpVueLoader.js"></script>
  14. <script src="../../static/kj/jquery.min.js"></script>
  15. <script src="../../static/kj/layer/layer.js"></script>
  16. <script src="../../static/sa.js"></script>
  17. <script src="../../static/kj/upload-util.js"></script>
  18. <style type="text/css">
  19. .c-panel .el-form .c-label {
  20. width: 7em !important;
  21. }
  22. .c-panel .el-form .c-panel .el-form {
  23. width: 180px;
  24. }
  25. .item-num .el-input__inner {
  26. width: 130px;
  27. }
  28. .xj {
  29. display: inline;
  30. color: red;
  31. margin-left: 9px;
  32. font-weight: bold;
  33. }
  34. .hj {
  35. color: red;
  36. margin-left: 9px;
  37. font-weight: bold;
  38. }
  39. </style>
  40. </head>
  41. <body>
  42. <div class="vue-box sbot" style="display: none;" :style="'display: block;'">
  43. <!-- ------- 内容部分 ------- -->
  44. <div class="s-body">
  45. <div class="c-panel">
  46. <div class="c-title">数据添加</div>
  47. <el-form v-if="m" label-position="left">
  48. <el-row>
  49. <el-card class="box-card">
  50. <div slot="header" class="clearfix">
  51. <span>基本资料</span>
  52. </div>
  53. <div>
  54. <el-row>
  55. <el-col span=8>
  56. <div class="c-item">
  57. <label class="c-label"><span style="color: red;">*</span>业务项目:</label>
  58. <el-select v-model="m.goodsId" placeholder="请选择" @change="goodsChange">
  59. <el-option v-for="item in goodsList" :key="item.id"
  60. :label="item.name" :value="item.id">
  61. </el-option>
  62. </el-select>
  63. </div>
  64. </el-col>
  65. <el-col span=8>
  66. <div class="c-item" v-if="goods.needCustomer">
  67. <label class="c-label"><span style="color: red;">*</span>客户:</label>
  68. <el-select
  69. :disabled="currentCustomerId!='1'"
  70. v-model="m.customerId" placeholder="请选择" filterable>
  71. <el-option v-for="item in customerList" :key="item.id"
  72. :label="item.name" :value="item.id">
  73. </el-option>
  74. </el-select>
  75. </div>
  76. <div class="c-item" v-if="goods.needOwner==1">
  77. <label class="c-label">
  78. <span style="color: red;">*</span>
  79. 货物名称:</label>
  80. <el-input v-model="m.businessGoodsName" placeholder="填写货物" clearable>
  81. </el-input>
  82. </div>
  83. </el-col>
  84. <el-col span=8>
  85. <div class="c-item">
  86. <label class="c-label">作业人员:</label>
  87. <el-input v-model="m.operator" placeholder="作业人员" clearable>
  88. </el-input>
  89. </div>
  90. <div class="c-item" v-if="goods.needOperateTime==1">
  91. <label class="c-label"><span style="color: red;">*</span>数量(件):</label>
  92. <el-input-number class="item-num" v-model="m.businessGoodsNum" :min="1"
  93. :max="99999" size="mini">
  94. </el-input-number>
  95. </div>
  96. </el-col>
  97. </el-row>
  98. </div>
  99. </el-card>
  100. </el-row>
  101. <el-row>
  102. <el-card class="box-card">
  103. <div slot="header" class="clearfix">
  104. <span>车辆</span>
  105. <el-button style="float: right;" icon="el-icon-plus" type="primary"
  106. @click="showAddModal" v-if="goods.mulCar==1||car.list.length==0">添加
  107. </el-button>
  108. </div>
  109. <el-table :data="car.list">
  110. <el-table-column type="index" width="50" label="序号">
  111. </el-table-column>
  112. <el-table-column prop="carNo" label="车牌号">
  113. </el-table-column>
  114. <el-table-column prop="carSize" label="规格(米)">
  115. </el-table-column>
  116. <el-table-column prop="carType" label="类型">
  117. </el-table-column>
  118. <el-table-column prop="netWeight" label="载重(kg)">
  119. </el-table-column>
  120. <el-table-column label="操作">
  121. <template slot-scope="s">
  122. <el-button class="c-btn" type="info" @click="editFn(s.row)">修改</el-button>
  123. <el-button class="c-btn" type="danger" @click="deleteFn(s.row)">删除
  124. </el-button>
  125. </template>
  126. </el-table-column>
  127. </el-table>
  128. </el-card>
  129. </el-row>
  130. <el-row>
  131. <el-card class="box-card">
  132. <div slot="header" class="clearfix">
  133. <span>收费项</span>
  134. </div>
  135. <div>
  136. <el-form-item v-for="(type,index) in itemTypeList">
  137. <el-row justify="center">
  138. <el-col span="16">
  139. <label style="color: red;"
  140. v-if="type.need==1">*</label><label>{{type.name}}:</label>
  141. <el-select v-model="type.itemId" style="width: 120px;"
  142. @change="itemChange(type)" placeholder="请选择">
  143. <el-option v-for="item in type.items" :key="item.id"
  144. :label="item.itemName" :value="item.id">
  145. </el-option>
  146. </el-select>
  147. </el-col>
  148. <el-col span="8">
  149. <el-input-number style="margin-left: 60px;" class="item-num"
  150. v-model="type.num" :min="1" :max="10" size="mini"></el-input-number>
  151. <div class="xj" v-if="type.itemId">
  152. {{type.price * type.num}}元
  153. <label @click="cleanItem(type)"
  154. style="margin-left: 5px;cursor: pointer">(<i
  155. class="el-icon-delete"></i>)</label>
  156. </div>
  157. </el-col>
  158. </el-row>
  159. <el-divider></el-divider>
  160. </el-form-item>
  161. <div class="hj" v-if="totalPrice>0">
  162. 合计费用:{{totalPrice}}<label>元</label>
  163. </div>
  164. </div>
  165. </el-card>
  166. </el-row>
  167. </el-form>
  168. </div>
  169. </div>
  170. <!-- ------- 底部按钮 ------- -->
  171. <div class="s-foot">
  172. <el-button type="primary" @click="ok()">确定</el-button>
  173. <el-button @click="closeFn()">取消</el-button>
  174. </div>
  175. <el-dialog title="车辆录入" :visible.sync="car.visible" width="400">
  176. <span>
  177. <el-form label-position="left">
  178. <div class="c-item">
  179. <label class="c-label"><span style="color: red;">*</span>车牌号:</label>
  180. <el-autocomplete v-model="car.form.carNo" placeholder="请输入车牌号" value-key='carNo'
  181. :fetch-suggestions="queryCarAsync">
  182. </el-autocomplete>
  183. </div>
  184. <div class="c-item">
  185. <label class="c-label">车辆类型:</label>
  186. <el-select v-model="car.form.carType" placeholder="请选择" @change="carTypeChange">
  187. <el-option :label="item.name" :value="item.name" v-for="(item,index) in carTypeList">
  188. </el-option>
  189. </el-select>
  190. </div>
  191. <div class="c-item">
  192. <label class="c-label">
  193. <span style="color: red;" v-if="goods.needCarSize==1">*</span>
  194. 规格(米):</label>
  195. <el-input-number class="item-num" v-model="car.form.carSize" :min="1" :max="50">
  196. </el-input-number>
  197. </div>
  198. <div class="c-item" v-if="car.form.carType&&car.form.carType.indexOf('空')==-1">
  199. <label class="c-label">
  200. <span style="color: red;" v-if="goods.needCarSize==1">*</span>
  201. 载重(kg):</label>
  202. <el-input-number class="item-num" v-model="car.form.netWeight" :min="1" :max="999999">
  203. </el-input-number>
  204. </div>
  205. </el-form>
  206. </span>
  207. <span slot="footer" class="dialog-footer">
  208. <el-button @click="car.visible = false">取 消</el-button>
  209. <el-button type="primary" @click="confirmAdd">确 定</el-button>
  210. </span>
  211. </el-dialog>
  212. <el-dialog title="申报单" :visible.sync="declare.visible" width="90%">
  213. <div class="delect-search">
  214. 申报人:
  215. <el-input style="width: 140px;" v-model="declare.p.declarePeople" placeholder="申报人">
  216. </el-input>
  217. <el-button type="primary" @click="getDeclareList">搜索</el-button>
  218. <el-button type="info" @click="resetDclare">重置</el-button>
  219. </div>
  220. <el-card class="box-card" style="margin-top: 20px;">
  221. <div slot="header">
  222. <span>列表</span>
  223. </div>
  224. <el-table :data="declare.list" ref="declareTable">
  225. <el-table-column type="selection">
  226. </el-table-column>
  227. <el-table-column prop="declarePeople" label="申报人">
  228. </el-table-column>
  229. <el-table-column prop="customerName" label="申报公司" width=200>
  230. </el-table-column>
  231. <el-table-column prop="sendUnit" label="货主" width=200>
  232. </el-table-column>
  233. <el-table-column prop="createTime" width="140" label="申报时间">
  234. </el-table-column>
  235. <el-table-column prop="declareNo" width="180" label="申报单号">
  236. </el-table-column>
  237. <el-table-column prop="goodsName" label="产品学名">
  238. </el-table-column>
  239. <el-table-column prop="carNo" label="越南车牌">
  240. </el-table-column>
  241. <el-table-column prop="grossWeight" label="毛重(kg)">
  242. </el-table-column>
  243. </el-table>
  244. <div class="block">
  245. <el-pagination layout="prev, pager, next" @current-change="getDeclareList"
  246. :page-size="declare.p.pageSize" :total="declare.p.dataCount"
  247. :current-page="declare.p.pageNo">
  248. </el-pagination>
  249. </div>
  250. </el-card>
  251. <span slot="footer" class="dialog-footer">
  252. <el-button @click="declare.visible = false">取 消</el-button>
  253. <el-button type="primary" @click="confirmSelectDeclare">确 定</el-button>
  254. </span>
  255. </el-dialog>
  256. </div>
  257. <script>
  258. var app = new Vue({
  259. components: {
  260. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue'),
  261. "sa-td": httpVueLoader('../../sa-frame/com/sa-td.vue')
  262. },
  263. el: '.vue-box',
  264. data: {
  265. m: {
  266. id: sa.p('id', ''), // 主键
  267. customerId: '', // 客户id
  268. customerName: '', // 客户名称
  269. operateTime: '',
  270. no: '', // 编号
  271. goodsId: '',
  272. goodsName: '', // 商品
  273. }, // 实体对象
  274. customerList: [],
  275. carList: [],
  276. currentCustomerId: 1,
  277. itemTypeList: [],
  278. filterTypeList: [],
  279. goodsList: [],
  280. tableData: [],
  281. car: {
  282. visible: false,
  283. list: [],
  284. form: {
  285. carNo: '',
  286. carType: '',
  287. netWeight: '',
  288. carSize: ''
  289. }
  290. },
  291. declare: {
  292. visible: false,
  293. list: [],
  294. p: {
  295. pageNo: 1,
  296. pageSize: 8,
  297. dataCount: 0,
  298. declarePeople: '',
  299. production: '',
  300. declareNo: '1'
  301. }
  302. },
  303. goods: {
  304. id: '',
  305. name: '',
  306. needWeight: 1,
  307. needCarSize: 1,
  308. needDeclare: 1,
  309. needOperateTime: 1,
  310. mulCar: 0
  311. },
  312. carTypeList: [],
  313. intiItems: []
  314. },
  315. computed: {
  316. totalPrice() {
  317. let itemList = this.itemTypeList.filter(obj => obj.itemId);
  318. let price = 0;
  319. for (let i in itemList) {
  320. let type = itemList[i];
  321. let num = type.num;
  322. let items = type.items;
  323. for (let j in items) {
  324. let item = items[j];
  325. if (item.id == type.itemId) {
  326. price += num * item.price;
  327. break;
  328. }
  329. }
  330. }
  331. return price;
  332. }
  333. },
  334. methods: {
  335. resetDclare() {
  336. this.declare.p.pageNo = 1;
  337. this.declare.p.pageSize = 8;
  338. this.declare.p.production = '';
  339. this.declare.p.declarePeople = '';
  340. this.getDeclareList();
  341. },
  342. handlerDeclare() {
  343. this.declare.visible = true;
  344. this.getDeclareList();
  345. },
  346. getDeclareList() {
  347. let currentCustomerId = this.currentCustomerId;
  348. if (currentCustomerId != '1') {
  349. this.declare.p.customerId = this.currentCustomerId;
  350. }
  351. let declareNo = this.m.declareNo;
  352. if (declareNo) {
  353. this.declare.p.declareNo = declareNo;
  354. }
  355. sa.ajax('/TbDeclare/getNotBindList', sa.removeNull(this.declare.p), function(resp) {
  356. let list = resp.data;
  357. this.declare.list = list;
  358. this.declare.p.pageNo = resp.pageNo;
  359. this.declare.p.dataCount = resp.dataCount;
  360. list.forEach(row => {
  361. if (row.declareNo == this.m.declareNo) {
  362. this.$nextTick(() => {
  363. this.$refs['declareTable'].toggleRowSelection(row, true)
  364. })
  365. }
  366. })
  367. }.bind(this))
  368. },
  369. confirmSelectDeclare() {
  370. // 获取选中元素的id列表
  371. let selection = this.$refs['declareTable'].selection;
  372. let declareNo = sa.getArrayField(selection, 'declareNo');
  373. if (selection.length == 0) {
  374. return sa.msg('请至少选择一条数据')
  375. }
  376. if (selection.length > 1) {
  377. return sa.msg('只能选择一条数据')
  378. }
  379. let declare = selection[0];
  380. let oldNo = this.m.declareNo;
  381. if (oldNo && oldNo !== declare.declareNo) {
  382. this.car.list = [];
  383. }
  384. if (oldNo !== declare.declareNo) {
  385. this.m.declareNo = declare.declareNo;
  386. this.m.customerId = declare.customerId;
  387. this.m.customerName = declare.customerName;
  388. this.m.owner = declare.sendUnit;
  389. let carNo = declare.carNo;
  390. let grossWeight = declare.grossWeight;
  391. let carList = this.car.list;
  392. let exit = carList.filter(obj => obj.carNo == carNo).pop();
  393. if (!exit) {
  394. let car = {
  395. carNo: carNo,
  396. netWeight: grossWeight,
  397. carType: '载重'
  398. }
  399. this.car.list.push(car)
  400. }
  401. this.m.cardNo = declare.carNo;
  402. this.m.chinaCarNo = declare.chinaCarNo;
  403. this.m.netWeight = declare.grossWeight;
  404. let chinaCarNo = declare.chinaCarNo;
  405. if (chinaCarNo) {
  406. let list = [];
  407. chinaCarNo.replace(",", ",").split(",").forEach(carNo => {
  408. let exit = carList.filter(obj => obj.carNo == carNo).pop();
  409. if (!exit) {
  410. let car = {
  411. carNo: carNo,
  412. carType: '空车'
  413. }
  414. this.car.list.push(car)
  415. }
  416. })
  417. }
  418. this.filterItems();
  419. }
  420. this.declare.visible = false;
  421. },
  422. cleanItem(type) {
  423. type.itemId = '';
  424. type.itemName = '';
  425. type.price = '';
  426. },
  427. itemChange(type) {
  428. let itemId = type.itemId;
  429. let item = type.items.filter(obj => obj.id == itemId).pop();
  430. if (item) {
  431. type.inc = item.inc;
  432. type.price = item.price;
  433. }
  434. this.validBefore();
  435. },
  436. confirmAdd() {
  437. let list = this.car.list;
  438. let weightCar = list.filter(car => car.carType && car.carType.indexOf('空') == -1).pop();
  439. let carNo = this.car.form.carNo;
  440. let netWeight = this.car.form.netWeight;
  441. let goods = this.goods;
  442. let form = this.car.form;
  443. let carType = form.carType;
  444. if (!carNo) {
  445. sa.error('请录入车牌号')
  446. return false;
  447. }
  448. if (!form.carSize && goods.needCarSize == 1) {
  449. sa.error('请填入车辆规格')
  450. return false;
  451. }
  452. if (carType.indexOf('空') !== -1) {
  453. netWeight = 0;
  454. }
  455. let index = list.map(obj => obj.carNo).indexOf(carNo);
  456. if (index > -1) {
  457. list.splice(index, 1);
  458. }
  459. let carSize = form.carSize;
  460. let car = {
  461. id: form.id,
  462. carNo: form.carNo.toUpperCase(),
  463. carType: carType,
  464. carSize: carSize,
  465. netWeight: netWeight
  466. }
  467. this.car.list.push(car);
  468. this.car.visible = false;
  469. if (weightCar) {
  470. if (weightCar.carType == carType &&
  471. carSize == weightCar.carSize &&
  472. netWeight == weightCar.netWeight) {
  473. return;
  474. }
  475. }
  476. this.filterItems();
  477. },
  478. filterItems() {
  479. let carList = this.car.list;
  480. let filterTypeList = JSON.parse(JSON.stringify(this.filterTypeList));
  481. if (carList.length == 0) {
  482. this.itemTypeList = filterTypeList;
  483. return;
  484. }
  485. let car = this.car.form;
  486. if (car == null) {
  487. let checkList = carList.filter(obj => obj.carType.indexOf('空') === -1);
  488. if (checkList.length > 0) {
  489. car = checkList[0];
  490. }
  491. }
  492. let carSize = car.carSize;
  493. let carType = car.carType;
  494. if (carType.indexOf('空') !== -1 && carList.length > 1) {
  495. return;
  496. }
  497. let netWeight = car.netWeight;
  498. let tempList = [];
  499. for (let i in filterTypeList) {
  500. let type = filterTypeList[i];
  501. let items = type.items;
  502. if (carType) {
  503. items = items.filter(item => item.itemType && item.itemType.indexOf(carType) !== -1);
  504. }
  505. if (carSize && carSize > 1) {
  506. items = items.filter(item => item.minLength <= carSize && item.carLength >= carSize);
  507. }
  508. if (netWeight && netWeight > 1 && carType && carType.indexOf('空') == -1) {
  509. items = items.filter(item => item.minWeight <= netWeight && item.maxWeight >= netWeight);
  510. }
  511. let itemIds = items.map(item => item.id);
  512. if (itemIds.indexOf(type.itemId) == -1) {
  513. this.cleanItem(type);
  514. }
  515. type.items = items;
  516. tempList.push(type);
  517. }
  518. this.itemTypeList = tempList;
  519. },
  520. showAddModal() {
  521. this.car.visible = true;
  522. this.car.form.carNo = '';
  523. this.car.form.carSize = '';
  524. this.car.form.netWeight = '';
  525. },
  526. editFn(data) {
  527. if (data.confirmJudge === 1) {
  528. sa.error('该车辆已审核,请先驳回审核在修改');
  529. return;
  530. }
  531. Object.assign(this.car, {
  532. visible: true,
  533. form: JSON.parse(JSON.stringify(data))
  534. })
  535. },
  536. deleteFn(data) {
  537. let confirmJudge = data.confirmJudge;
  538. if (confirmJudge == 1) {
  539. sa.error('业务已审核,请先驳回');
  540. return;
  541. }
  542. this.car.list.splice(this.car.list.indexOf(data), 1);
  543. this.filterItems();
  544. },
  545. getGoods() {
  546. sa.ajaxNoLoading('/TbGoods/getList', {
  547. pageNo: 1,
  548. pageSize: 10
  549. }, function(resp) {
  550. let list = resp.data;
  551. this.goods = list.filter(goods => goods.id == this.m.goodsId).pop();
  552. this.goodsList = list;
  553. this.getTypeByGoodsId();
  554. }.bind(this))
  555. },
  556. goodsChange(v) {
  557. let goodsList = this.goodsList;
  558. let goods = goodsList.filter(goods => goods.id == v).pop();
  559. this.goods = goods;
  560. this.m.goodsName = goods.name;
  561. this.getTypeByGoodsId();
  562. },
  563. getTypeByGoodsId() {
  564. sa.ajax('/TbItemType/getTypeByGoodsId', {
  565. goodsId: this.m.goodsId
  566. }, function(resp) {
  567. let list = resp.data;
  568. let initItems = this.intiItems;
  569. for (let i in initItems) {
  570. let initItem = initItems[i];
  571. for (let j in list) {
  572. let type = list[j];
  573. if (type.id == initItem.itemTypeId) {
  574. type.num = initItem.num;
  575. type.price = initItem.itemPrice;
  576. type.itemId = initItem.itemId;
  577. type.remark = initItem.remark;
  578. }
  579. }
  580. }
  581. this.itemTypeList = list;
  582. this.filterTypeList = JSON.parse(JSON.stringify(this.itemTypeList));
  583. //this.filterItems();
  584. }.bind(this))
  585. },
  586. getItemType() {
  587. sa.ajax('/TbItem/getItemType', function(resp) {
  588. let list = resp.data;
  589. if (list.length > 0) {
  590. this.car.form.carType = list[0].name;
  591. }
  592. this.carTypeList = list;
  593. }.bind(this))
  594. },
  595. carTypeChange(v) {
  596. },
  597. getCustomerList() {
  598. sa.ajax('/TbCostomer/getList', {
  599. pageNo: 1,
  600. pageSize: 200,
  601. sortType: 20,
  602. judgeStatus: 2
  603. }, function(res) {
  604. let list = res.data;
  605. this.customerList = list;
  606. }.bind(this));
  607. },
  608. queryCarAsync(queryStr, cb) {
  609. sa.ajaxNoLoading('/TbBusinessCar/searchByNo', {
  610. carNo: queryStr
  611. }, function(resp) {
  612. cb(resp.data)
  613. }.bind(this))
  614. },
  615. closeFn() {
  616. parent.app.f5();
  617. sa.closeCurrIframe();
  618. },
  619. validBefore() {
  620. let goods = this.goods;
  621. let needCustomer = goods.needCustomer;
  622. let m = this.m;
  623. if (needCustomer == 1 && !m.customerId) {
  624. sa.error('请选择客户');
  625. return false;
  626. }
  627. if (goods.needOperateTime == 1 && (!m.businessGoodsNum || m.businessGoodsNum <= 0)) {
  628. sa.error('请输入件数');
  629. return false;
  630. }
  631. if (!m.businessGoodsName && goods.needOwner == 1) {
  632. sa.error('请填写货物');
  633. return false;
  634. }
  635. if (this.car.list.length == 0) {
  636. sa.error('请录入车辆');
  637. return false;
  638. }
  639. let needCarSize = goods.needCarSize;
  640. let carList = this.car.list;
  641. for (let i in carList) {
  642. let car = carList[i];
  643. if (needCarSize == 1 && !car.carSize) {
  644. sa.error('请补充' + car.carNo + '规格');
  645. return;
  646. }
  647. }
  648. },
  649. // 提交数据
  650. ok: function() {
  651. let goods = this.goods;
  652. let m = this.m;
  653. if (!m.businessGoodsName && goods.needOwner == 1) {
  654. sa.error('请填写货物');
  655. return false;
  656. }
  657. if (goods.needOperateTime == 1 && (!m.businessGoodsNum||m.businessGoodsNum<=0)) {
  658. sa.error('请填写货物件数');
  659. return false;
  660. }
  661. if (this.car.list.length == 0) {
  662. sa.error('请录入车辆');
  663. return false;
  664. }
  665. let carList = this.car.list;
  666. let needCarSize = goods.needCarSize;
  667. for (let i in carList) {
  668. let car = carList[i];
  669. if (needCarSize == 1 && !car.carSize) {
  670. sa.error('请补充' + car.carNo + '规格');
  671. return;
  672. }
  673. }
  674. let typeList = this.itemTypeList;
  675. let selectList = [];
  676. for (let i in typeList) {
  677. let type = typeList[i];
  678. if (type.need == 1 && !type.itemId) {
  679. sa.error(type.name + '必选');
  680. return false;
  681. }
  682. if (type.itemId) {
  683. let obj = {
  684. typeId: type.id,
  685. typeName: type.name,
  686. id: type.itemId,
  687. num: type.num,
  688. price: type.price,
  689. remark: type.remark
  690. }
  691. selectList.push(obj);
  692. }
  693. }
  694. m.itemJson = JSON.stringify(selectList);
  695. m.carJson = JSON.stringify(carList);
  696. let chinaCarNo = carList
  697. .filter(car => sa.isCarNo(car.carNo.toUpperCase()))
  698. .map(car => car.carNo.toUpperCase())
  699. .join("、");
  700. let yueCarNo = carList
  701. .filter(car => !sa.isCarNo(car.carNo.toUpperCase()))
  702. .map(car => car.carNo.toUpperCase())
  703. .join("、");
  704. m.cardNo = yueCarNo;
  705. m.chinaCarNo = chinaCarNo;
  706. m.cars = null;
  707. m.items = null;
  708. sa.ajax('/TbBusiness/editOtherBusiness', sa.removeNull(m), function(res) {
  709. sa.alert('修改成功', this.clean);
  710. }.bind(this));
  711. },
  712. // 添加/修改 完成后的动作
  713. clean: function() {
  714. parent.app.f5(); // 刷新父页面列表
  715. sa.closeCurrIframe(); // 关闭本页
  716. },
  717. getCurrentCustomer() {
  718. sa.ajax('/TbCostomer/getCurrentCustomerId', function(resp) {
  719. let id = resp.data;
  720. this.currentCustomerId = id;
  721. }.bind(this));
  722. },
  723. getOtherBusinessById() {
  724. sa.ajax('/TbBusiness/getOtherBusinessById?id=' + this.m.id, function(resp) {
  725. let data = resp.data;
  726. this.car.list = data.cars;
  727. this.intiItems = data.items;
  728. this.m = resp.data;
  729. this.getGoods();
  730. }.bind(this))
  731. },
  732. },
  733. mounted: function() {
  734. this.getCurrentCustomer();
  735. this.getOtherBusinessById();
  736. this.getCustomerList();
  737. this.getItemType();
  738. }
  739. })
  740. </script>
  741. </body>
  742. </html>