tb-business-edit.html 33 KB

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