tb-business-add.html 25 KB

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