tb-business-edit.html 25 KB

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