tb-car-disincle-edit.html 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780
  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" v-if="goods.needCustomer">
  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.businessGoodsName" 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" v-if="goods.needOperateTime==1">
  103. <label class="c-label"><span style="color: red;">*</span>件数:</label>
  104. <el-input-number class="item-num" v-model="m.businessGoodsNum" :min="1"
  105. :max="99999" size="mini">
  106. </el-input-number>
  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" v-if="goods.mulCar==1||car.list.length==0">添加
  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. mulCar: 0
  330. },
  331. carTypeList: [],
  332. intiItems: []
  333. },
  334. computed: {
  335. totalPrice() {
  336. let itemList = this.itemTypeList.filter(obj => obj.itemId);
  337. let price = 0;
  338. for (let i in itemList) {
  339. let type = itemList[i];
  340. let num = type.num;
  341. let items = type.items;
  342. for (let j in items) {
  343. let item = items[j];
  344. if (item.id == type.itemId) {
  345. price += num * item.price;
  346. break;
  347. }
  348. }
  349. }
  350. return price;
  351. }
  352. },
  353. methods: {
  354. resetDclare() {
  355. this.declare.p.pageNo = 1;
  356. this.declare.p.pageSize = 8;
  357. this.declare.p.production = '';
  358. this.declare.p.declarePeople = '';
  359. this.getDeclareList();
  360. },
  361. handlerDeclare() {
  362. this.declare.visible = true;
  363. this.getDeclareList();
  364. },
  365. getDeclareList() {
  366. let currentCustomerId = this.currentCustomerId;
  367. if (currentCustomerId != '1') {
  368. this.declare.p.customerId = this.currentCustomerId;
  369. }
  370. let declareNo = this.m.declareNo;
  371. if (declareNo) {
  372. this.declare.p.declareNo = declareNo;
  373. }
  374. sa.ajax('/TbDeclare/getNotBindList', sa.removeNull(this.declare.p), function(resp) {
  375. let list = resp.data;
  376. this.declare.list = list;
  377. this.declare.p.pageNo = resp.pageNo;
  378. this.declare.p.dataCount = resp.dataCount;
  379. list.forEach(row => {
  380. if (row.declareNo == this.m.declareNo) {
  381. this.$nextTick(() => {
  382. this.$refs['declareTable'].toggleRowSelection(row, true)
  383. })
  384. }
  385. })
  386. }.bind(this))
  387. },
  388. confirmSelectDeclare() {
  389. // 获取选中元素的id列表
  390. let selection = this.$refs['declareTable'].selection;
  391. let declareNo = sa.getArrayField(selection, 'declareNo');
  392. if (selection.length == 0) {
  393. return sa.msg('请至少选择一条数据')
  394. }
  395. if (selection.length > 1) {
  396. return sa.msg('只能选择一条数据')
  397. }
  398. let declare = selection[0];
  399. let oldNo = this.m.declareNo;
  400. if (oldNo && oldNo !== declare.declareNo) {
  401. this.car.list = [];
  402. }
  403. if (oldNo !== declare.declareNo) {
  404. this.m.declareNo = declare.declareNo;
  405. this.m.customerId = declare.customerId;
  406. this.m.customerName = declare.customerName;
  407. this.m.owner = declare.sendUnit;
  408. let carNo = declare.carNo;
  409. let grossWeight = declare.grossWeight;
  410. let carList = this.car.list;
  411. let exit = carList.filter(obj => obj.carNo == carNo).pop();
  412. if (!exit) {
  413. let car = {
  414. carNo: carNo,
  415. netWeight: grossWeight,
  416. carType: '载重'
  417. }
  418. this.car.list.push(car)
  419. }
  420. this.m.cardNo = declare.carNo;
  421. this.m.chinaCarNo = declare.chinaCarNo;
  422. this.m.netWeight = declare.grossWeight;
  423. let chinaCarNo = declare.chinaCarNo;
  424. if (chinaCarNo) {
  425. let list = [];
  426. chinaCarNo.replace(",", ",").split(",").forEach(carNo => {
  427. let exit = carList.filter(obj => obj.carNo == carNo).pop();
  428. if (!exit) {
  429. let car = {
  430. carNo: carNo,
  431. carType: '空车'
  432. }
  433. this.car.list.push(car)
  434. }
  435. })
  436. }
  437. this.filterItems();
  438. }
  439. this.declare.visible = false;
  440. },
  441. cleanItem(type) {
  442. type.itemId = '';
  443. type.itemName = '';
  444. type.price = '';
  445. },
  446. itemChange(type) {
  447. let itemId = type.itemId;
  448. let item = type.items.filter(obj => obj.id == itemId).pop();
  449. if (item) {
  450. type.inc = item.inc;
  451. type.price = item.price;
  452. }
  453. this.validBefore();
  454. },
  455. confirmAdd() {
  456. let list = this.car.list;
  457. let weightCar = list.filter(car => car.carType && car.carType.indexOf('空') == -1).pop();
  458. let carNo = this.car.form.carNo;
  459. let netWeight = this.car.form.netWeight;
  460. let goods = this.goods;
  461. let form = this.car.form;
  462. let carType = form.carType;
  463. if (!carNo) {
  464. sa.error('请录入车牌号')
  465. return false;
  466. }
  467. if (!form.carSize && goods.needCarSize == 1) {
  468. sa.error('请填入车辆规格')
  469. return false;
  470. }
  471. if (carType.indexOf('空') !== -1) {
  472. netWeight = 0;
  473. }
  474. let index = list.map(obj => obj.carNo).indexOf(carNo);
  475. if (index > -1) {
  476. list.splice(index, 1);
  477. }
  478. let carSize = form.carSize;
  479. let car = {
  480. id: form.id,
  481. carNo: form.carNo.toUpperCase(),
  482. carType: carType,
  483. carSize: carSize,
  484. netWeight: netWeight
  485. }
  486. this.car.list.push(car);
  487. this.car.visible = false;
  488. if (weightCar) {
  489. if (weightCar.carType == carType &&
  490. carSize == weightCar.carSize &&
  491. netWeight == weightCar.netWeight) {
  492. return;
  493. }
  494. }
  495. this.filterItems();
  496. },
  497. filterItems() {
  498. let carList = this.car.list;
  499. let filterTypeList = JSON.parse(JSON.stringify(this.filterTypeList));
  500. if (carList.length == 0) {
  501. this.itemTypeList = filterTypeList;
  502. return;
  503. }
  504. let car = this.car.form;
  505. if (car == null) {
  506. let checkList = carList.filter(obj => obj.carType.indexOf('空') === -1);
  507. if (checkList.length > 0) {
  508. car = checkList[0];
  509. }
  510. }
  511. let carSize = car.carSize;
  512. let carType = car.carType;
  513. if (carType.indexOf('空') !== -1 && carList.length > 1) {
  514. return;
  515. }
  516. let netWeight = car.netWeight;
  517. let tempList = [];
  518. for (let i in filterTypeList) {
  519. let type = filterTypeList[i];
  520. let items = type.items;
  521. if (carType) {
  522. items = items.filter(item => item.itemType && item.itemType.indexOf(carType) !== -1);
  523. }
  524. if (carSize && carSize > 1) {
  525. items = items.filter(item => item.minLength <= carSize && item.carLength >= carSize);
  526. }
  527. if (netWeight && netWeight > 1 && carType && carType.indexOf('空') == -1) {
  528. items = items.filter(item => item.minWeight <= netWeight && item.maxWeight >= netWeight);
  529. }
  530. let itemIds = items.map(item => item.id);
  531. if (itemIds.indexOf(type.itemId) == -1) {
  532. this.cleanItem(type);
  533. }
  534. type.items = items;
  535. tempList.push(type);
  536. }
  537. this.itemTypeList = tempList;
  538. },
  539. showAddModal() {
  540. this.car.visible = true;
  541. this.car.form.carNo = '';
  542. this.car.form.carSize = '';
  543. this.car.form.netWeight = '';
  544. },
  545. editFn(data) {
  546. if (data.confirmJudge === 1) {
  547. sa.error('该车辆已审核,请先驳回审核在修改');
  548. return;
  549. }
  550. Object.assign(this.car, {
  551. visible: true,
  552. form: JSON.parse(JSON.stringify(data))
  553. })
  554. },
  555. deleteFn(data) {
  556. let confirmJudge = data.confirmJudge;
  557. if (confirmJudge == 1) {
  558. sa.error('业务已审核,请先驳回');
  559. return;
  560. }
  561. this.car.list.splice(this.car.list.indexOf(data), 1);
  562. this.filterItems();
  563. },
  564. getGoods() {
  565. sa.ajaxNoLoading('/TbGoods/getList', {
  566. pageNo: 1,
  567. pageSize: 10
  568. }, function(resp) {
  569. let list = resp.data;
  570. this.goods = list.filter(goods => goods.id == this.m.goodsId).pop();
  571. this.goodsList = list;
  572. this.getTypeByGoodsId();
  573. }.bind(this))
  574. },
  575. goodsChange(v) {
  576. let goodsList = this.goodsList;
  577. let goods = goodsList.filter(goods => goods.id == v).pop();
  578. this.goods = goods;
  579. this.m.goodsName = goods.name;
  580. this.getTypeByGoodsId();
  581. },
  582. getTypeByGoodsId() {
  583. sa.ajax('/TbItemType/getTypeByGoodsId', {
  584. goodsId: this.m.goodsId
  585. }, function(resp) {
  586. let list = resp.data;
  587. let initItems = this.intiItems;
  588. for (let i in initItems) {
  589. let initItem = initItems[i];
  590. for (let j in list) {
  591. let type = list[j];
  592. if (type.id == initItem.itemTypeId) {
  593. type.num = initItem.num;
  594. type.price = initItem.itemPrice;
  595. type.itemId = initItem.itemId;
  596. type.remark = initItem.remark;
  597. }
  598. }
  599. }
  600. this.itemTypeList = list;
  601. this.filterTypeList = JSON.parse(JSON.stringify(this.itemTypeList));
  602. //this.filterItems();
  603. }.bind(this))
  604. },
  605. getItemType() {
  606. sa.ajax('/TbItem/getItemType', function(resp) {
  607. let list = resp.data;
  608. if (list.length > 0) {
  609. this.car.form.carType = list[0].name;
  610. }
  611. this.carTypeList = list;
  612. }.bind(this))
  613. },
  614. carTypeChange(v) {
  615. },
  616. getCustomerList() {
  617. sa.ajax('/TbCostomer/getList', {
  618. pageNo: 1,
  619. pageSize: 30,
  620. sortType: 20,
  621. judgeStatus: 2
  622. }, function(res) {
  623. let list = res.data;
  624. this.customerList = list;
  625. }.bind(this));
  626. },
  627. queryCarAsync(queryStr, cb) {
  628. sa.ajaxNoLoading('/TbBusinessCar/searchByNo', {
  629. carNo: queryStr
  630. }, function(resp) {
  631. cb(resp.data)
  632. }.bind(this))
  633. },
  634. closeFn() {
  635. parent.app.f5();
  636. sa.closeCurrIframe();
  637. },
  638. validBefore() {
  639. let goods = this.goods;
  640. let needCustomer = goods.needCustomer;
  641. let m = this.m;
  642. if (goods.needDeclare == 1 && !m.declareNo) {
  643. sa.error('请选择申报单');
  644. return false;
  645. }
  646. if (needCustomer == 1 && !m.customerId) {
  647. sa.error('请选择客户');
  648. return false;
  649. }
  650. if (goods.needOperateTime == 1 && (!m.businessGoodsNum || m.businessGoodsNum <= 0)) {
  651. sa.error('请输入件数');
  652. return false;
  653. }
  654. if (!m.businessGoodsName && goods.needOwner == 1) {
  655. sa.error('请填写货物');
  656. return false;
  657. }
  658. if (this.car.list.length == 0) {
  659. sa.error('请录入车辆');
  660. return false;
  661. }
  662. let needCarSize = goods.needCarSize;
  663. let carList = this.car.list;
  664. for (let i in carList) {
  665. let car = carList[i];
  666. if (needCarSize == 1 && !car.carSize) {
  667. sa.error('请补充' + car.carNo + '规格');
  668. return;
  669. }
  670. }
  671. },
  672. // 提交数据
  673. ok: function() {
  674. let goods = this.goods;
  675. let m = this.m;
  676. if (goods.needDeclare == 1 && !m.declareNo) {
  677. sa.error('请选择申报单');
  678. return false;
  679. }
  680. if (!m.businessGoodsName && goods.needOwner == 1) {
  681. sa.error('请填写货物');
  682. return false;
  683. }
  684. if (goods.needOperateTime == 1 && (!m.businessGoodsNum||m.businessGoodsNum<=0)) {
  685. sa.error('请填写货物件数');
  686. return false;
  687. }
  688. if (this.car.list.length == 0) {
  689. sa.error('请录入车辆');
  690. return false;
  691. }
  692. let carList = this.car.list;
  693. let needCarSize = goods.needCarSize;
  694. for (let i in carList) {
  695. let car = carList[i];
  696. if (needCarSize == 1 && !car.carSize) {
  697. sa.error('请补充' + car.carNo + '规格');
  698. return;
  699. }
  700. }
  701. let typeList = this.itemTypeList;
  702. let selectList = [];
  703. for (let i in typeList) {
  704. let type = typeList[i];
  705. if (type.need == 1 && !type.itemId) {
  706. sa.error(type.name + '必选');
  707. return false;
  708. }
  709. if (type.itemId) {
  710. let obj = {
  711. typeId: type.id,
  712. typeName: type.name,
  713. id: type.itemId,
  714. num: type.num,
  715. price: type.price,
  716. remark: type.remark
  717. }
  718. selectList.push(obj);
  719. }
  720. }
  721. m.itemJson = JSON.stringify(selectList);
  722. m.carJson = JSON.stringify(carList);
  723. let chinaCarNo = carList
  724. .filter(car => sa.isCarNo(car.carNo.toUpperCase()))
  725. .map(car => car.carNo.toUpperCase())
  726. .join("、");
  727. let yueCarNo = carList
  728. .filter(car => !sa.isCarNo(car.carNo.toUpperCase()))
  729. .map(car => car.carNo.toUpperCase())
  730. .join("、");
  731. m.cardNo = yueCarNo;
  732. m.chinaCarNo = chinaCarNo;
  733. m.cars = null;
  734. m.items = null;
  735. sa.ajax('/TbBusiness/editOtherBusiness', sa.removeNull(m), function(res) {
  736. sa.alert('修改成功', this.clean);
  737. }.bind(this));
  738. },
  739. // 添加/修改 完成后的动作
  740. clean: function() {
  741. parent.app.f5(); // 刷新父页面列表
  742. sa.closeCurrIframe(); // 关闭本页
  743. },
  744. getCurrentCustomer() {
  745. sa.ajax('/TbCostomer/getCurrentCustomerId', function(resp) {
  746. let id = resp.data;
  747. this.currentCustomerId = id;
  748. }.bind(this));
  749. },
  750. getOtherBusinessById() {
  751. sa.ajax('/TbBusiness/getOtherBusinessById?id=' + this.m.id, function(resp) {
  752. let data = resp.data;
  753. this.car.list = data.cars;
  754. this.intiItems = data.items;
  755. this.m = resp.data;
  756. this.getGoods();
  757. }.bind(this))
  758. },
  759. },
  760. mounted: function() {
  761. this.getCurrentCustomer();
  762. this.getOtherBusinessById();
  763. this.getCustomerList();
  764. this.getItemType();
  765. }
  766. })
  767. </script>
  768. </body>
  769. </html>