tb-car-disincle-add.html 23 KB

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