tb-car-disincle-edit.html 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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. </style>
  29. </head>
  30. <body>
  31. <div class="vue-box" :class="{sbot: id}" style="display: none;" :style="'display: block;'">
  32. <!-- ------- 内容部分 ------- -->
  33. <div class="s-body">
  34. <div class="c-panel">
  35. <div class="c-title" v-if="id == 0">数据添加</div>
  36. <div class="c-title" v-else>数据修改</div>
  37. <el-form v-if="m" label-position="left">
  38. <el-card class="box-card">
  39. <div slot="header" class="clearfix">
  40. <span>基本资料</span>
  41. </div>
  42. <el-row>
  43. <el-col :span='12'>
  44. <div class="c-item" v-if="currentCustomerId=='1'">
  45. <label class="c-label"><span style="color: red;">*</span>客户:</label>
  46. <el-select v-model="m.customerId" placeholder="请选择">
  47. <el-option v-for="item in customerList" :key="item.id" :label="item.name"
  48. :value="item.id">
  49. </el-option>
  50. </el-select>
  51. </div>
  52. <sa-item name="车牌号" placeholder="请输入车牌号" v-model="m.carNo" br>
  53. </sa-item>
  54. <sa-item type="num" name="车辆规格(米)" placeholder="请输入车辆规格" v-model="m.carSize" br>
  55. </sa-item>
  56. <sa-item name="作业人员" placeholder="请输入作业人员" v-model="m.operator" br>
  57. </sa-item>
  58. </el-col>
  59. <el-col :span='12'>
  60. <div class="c-item">
  61. <label class="c-label">车辆类型:</label>
  62. <el-select v-model="m.carType" placeholder="请选择" @change="carTypeChange">
  63. <el-option :label="item.name" :value="item.name"
  64. v-for="(item,index) in carTypeList">
  65. </el-option>
  66. </el-select>
  67. </div>
  68. <sa-item v-if="m.carType.indexOf('重')!==-1" type="num" name="载重(kg)"
  69. placeholder="请输入车辆载重" v-model="m.carWeight" br>
  70. </sa-item>
  71. <div class="c-item">
  72. <label class="c-label">作业时间:</label>
  73. <el-date-picker type="datetime" value-format="yyyy-MM-dd HH:mm:ss"
  74. v-model="m.operateTime"></el-date-picker>
  75. </div>
  76. </el-col>
  77. </el-row>
  78. <el-card class="box-card">
  79. <div slot="header" class="clearfix">
  80. <span>收费明细<label style="color: red;">(总共{{totalPrice}}元)</label></span>
  81. <el-select v-model="m.itemTypeId" placeholder="请选择" @change="itemChange"
  82. style="float: right; padding: 3px 0">
  83. <el-option v-for="(item,index) in itemTypeList" :label="item.name"
  84. :value="item.id">
  85. </el-option>
  86. </el-select>
  87. </div>
  88. <div>
  89. <el-checkbox-group v-model="checkList">
  90. <el-row v-for="(item,index) in items"
  91. style="border-bottom: 1px solid #E4E4E4;line-height: 90px;">
  92. <el-col :span="11">
  93. <el-checkbox :disabled="item.need==1" :label="item.id">
  94. <div>{{item.itemName}}(<label
  95. style="color: red;">{{item.price}}{{item.unit}}</label>)
  96. </div>
  97. </el-checkbox>
  98. </el-col>
  99. <el-col :span="6">
  100. <el-input-number :disabled="item.inc==0" class="item-num"
  101. v-model="item.num" :min="1" :max="10"></el-input-number>
  102. </el-col>
  103. <el-col :span="7">
  104. <sa-item type="textarea" name="备注" placeholder="请输入备注"
  105. v-model="item.remark" br>
  106. </sa-item>
  107. </el-col>
  108. </el-row>
  109. </el-checkbox-group>
  110. </div>
  111. </el-card>
  112. </el-form>
  113. </div>
  114. </div>
  115. <!-- ------- 底部按钮 ------- -->
  116. <div class="s-foot">
  117. <el-button type="primary" @click="ok()">确定</el-button>
  118. <el-button @click="sa.closeCurrIframe()">取消</el-button>
  119. </div>
  120. </div>
  121. <script>
  122. var app = new Vue({
  123. components: {
  124. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue'),
  125. "sa-td": httpVueLoader('../../sa-frame/com/sa-td.vue')
  126. },
  127. el: '.vue-box',
  128. data: {
  129. id: sa.p('id', ''),
  130. p: { // 查询参数
  131. business: 0,
  132. pageNo: 1, // 当前页
  133. pageSize: 50, // 页大小
  134. sortType: 0 // 排序方式
  135. },
  136. id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
  137. m: {
  138. id: '', // 主键
  139. carNo: '',
  140. carSize: '',
  141. carType: '载重',
  142. carWeight: '',
  143. itemTypeId: ''
  144. }, // 实体对象
  145. itemTypeList: [],
  146. items: [],
  147. businessItems: [],
  148. checkList: [],
  149. customerList: [],
  150. carTypeList: [],
  151. currentCustomerId: ''
  152. },
  153. computed: {
  154. totalPrice() {
  155. let checkList = this.checkList;
  156. let items = this.items
  157. .filter(obj => checkList.indexOf(obj.id) !== -1);
  158. let price = 0;
  159. for (let i in items) {
  160. let item = items[i];
  161. price = price + item.price * item.num;
  162. }
  163. return price;
  164. }
  165. },
  166. methods: {
  167. itemChange() {
  168. sa.ajax('/TbItem/getTypeItemList', {
  169. pageNo: 1,
  170. pageSize: 30,
  171. typeId: this.m.itemTypeId
  172. }, function(resp) {
  173. let list = resp.data;
  174. if (this.m.carType) {
  175. list = list.filter(obj => obj.itemType && obj.itemType.indexOf(this.m
  176. .carType) !== -1);
  177. }
  178. this.items = list;
  179. this.checkList = list.filter(obj => obj.need == 1 || obj.itemType.indexOf(this.m
  180. .carType) !== -1).map(obj => obj.id);
  181. let businessItems = this.businessItems;
  182. list.forEach(obj => {
  183. businessItems.forEach(item => {
  184. if (obj.id == item.itemId) {
  185. obj.remark = item.remark;
  186. obj.num = item.num;
  187. }
  188. })
  189. })
  190. }.bind(this))
  191. },
  192. getCustomer() {
  193. sa.ajax('/TbCostomer/getCurrentCustomerId', function(resp) {
  194. let id = resp.data;
  195. if (id == 1) {
  196. this.getCustomerList();
  197. } else {
  198. this.m.customerId = id;
  199. }
  200. this.currentCustomerId = id;
  201. }.bind(this));
  202. },
  203. carTypeChange(v) {
  204. this.getItems();
  205. },
  206. getItemType() {
  207. sa.ajax('/TbItem/getItemType', function(resp) {
  208. this.carTypeList = resp.data;
  209. }.bind(this))
  210. },
  211. getCustomerList() {
  212. sa.ajax('/TbCostomer/getList', {
  213. pageNo: 1,
  214. pageSize: 30,
  215. sortType: 20,
  216. judgeStatus: 2
  217. }, function(res) {
  218. this.customerList = res.data; // 数据
  219. }.bind(this));
  220. },
  221. getItemTypeList() {
  222. sa.ajax('/TbItemType/getList', sa.removeNull(this.p), function(res) {
  223. let list = res.data;
  224. this.itemTypeList = list;
  225. this.getItems();
  226. }.bind(this));
  227. },
  228. getItems() {
  229. sa.ajax('/TbItem/getTypeItemList', {
  230. pageNo: 1,
  231. pageSize: 30,
  232. typeId: this.m.itemTypeId
  233. }, function(resp) {
  234. let list = resp.data;
  235. if (this.m.carType) {
  236. list = list.filter(obj => obj.itemType && obj.itemType.indexOf(this.m
  237. .carType) !== -1);
  238. }
  239. this.items = list;
  240. this.checkList = list.filter(obj => obj.need == 1 || obj.itemType.indexOf(this.m
  241. .carType) !== -1).map(obj => obj.id);
  242. let businessItems = this.businessItems;
  243. list.forEach(obj => {
  244. businessItems.forEach(item => {
  245. if (obj.id == item.itemId) {
  246. obj.remark = item.remark;
  247. obj.num = item.num;
  248. }
  249. })
  250. })
  251. }.bind(this))
  252. },
  253. ok() {
  254. let m = this.m;
  255. if (!m.carNo) {
  256. sa.error('请输入车牌号')
  257. return false;
  258. }
  259. let checkList = this.checkList;
  260. let itemList = this.items;
  261. let list = itemList.filter(obj => checkList.indexOf(obj.id) !== -1);
  262. m.itemJson = JSON.stringify(list);
  263. m.items = null;
  264. sa.ajax('/api/editOtherBusiness', sa.removeNull(m), function(resp) {
  265. parent.app.f5(); // 刷新父页面列表
  266. sa.closeCurrIframe(); // 关闭本页
  267. }.bind(this))
  268. },
  269. getOtherBusinessById() {
  270. sa.ajax('/TbBusiness/getOtherBusinessById', {
  271. id: this.id
  272. }, function(resp) {
  273. let data = resp.data;
  274. this.m = data
  275. this.businessItems = data.items;
  276. this.checkList = data.items.map(obj => obj.itemId);
  277. console.log(this.checkList);
  278. this.getItemTypeList();
  279. this.getItemType();
  280. }.bind(this))
  281. }
  282. },
  283. mounted: function() {
  284. this.getOtherBusinessById();
  285. this.getCustomer();
  286. }
  287. })
  288. </script>
  289. </body>
  290. </html>