tb-business-add.html 25 KB

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