tb-car-disincle-edit.html 23 KB

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