tb-business-edit.html 27 KB

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