tb-supplement-add.html 27 KB

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