tb-business-add.html 32 KB

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