tb-supplement-edit.html 35 KB

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