tb-business-edit.html 25 KB

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