tb-declare-add.html 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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="https://unpkg.com/element-ui@2.13.0/lib/theme-chalk/index.css">
  10. <link rel="stylesheet" href="../../static/sa.css">
  11. <script src="https://unpkg.com/vue@2.6.10/dist/vue.js"></script>
  12. <script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
  13. <script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
  14. <script src="https://unpkg.com/jquery@3.4.1/dist/jquery.js"></script>
  15. <script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
  16. <script src="../../static/sa.js"></script>
  17. <style type="text/css">
  18. .c-panel .el-form .c-label {
  19. width: 15em !important;
  20. }
  21. .c-panel .el-form .el-input, .c-panel .el-form .el-textarea__inner {
  22. width: 250px;
  23. }
  24. </style>
  25. </head>
  26. <body>
  27. <div class="vue-box" :class="{sbot: id}" style="display: none;" :style="'display: block;'">
  28. <!-- ------- 内容部分 ------- -->
  29. <div class="s-body">
  30. <div class="c-panel">
  31. <div class="c-title" v-if="id == 0">数据添加</div>
  32. <div class="c-title" v-else>数据修改</div>
  33. <el-form v-if="m">
  34. <sa-item type="text" name="产品学名" v-model="m.goodsName" br></sa-item>
  35. <sa-item type="num" name="毛重(kg)" v-model="m.grossWeight" br></sa-item>
  36. <sa-item type="num" name="数量(件)" v-model="m.num" br></sa-item>
  37. <!-- <sa-item type="text" name="生产日期" v-model="m.productionDate" br></sa-item>-->
  38. <div class="c-item br">
  39. <label class="c-label">生产日期:</label>
  40. <el-date-picker type="date" value-format="yyyy-MM-dd" v-model="m.productionDate"
  41. placeholder="请选择"></el-date-picker>
  42. </div>
  43. <sa-item type="num" name="保质期(天)" v-model="m.expirationDate" br></sa-item>
  44. <sa-item type="text" name="储存条件" v-model="m.storageMode" br></sa-item>
  45. <sa-item type="text" name="生产方式" v-model="m.productionMode" br></sa-item>
  46. <sa-item type="text" name="原产国" v-model="m.origin" br></sa-item>
  47. <sa-item type="text" name="进口冷链食品生产商注册号" v-model="m.producerCode" br></sa-item>
  48. <sa-item type="text" name="货主单位" v-model="m.sendUnit" br></sa-item>
  49. <sa-item type="text" name="收货单位" v-model="m.receiveUnit" br></sa-item>
  50. <sa-item type="text" name="货物流向" v-model="m.route" br></sa-item>
  51. <sa-item type="text" name="司机姓名" v-model="m.driverName" br></sa-item>
  52. <sa-item type="text" name="司机电话" v-model="m.driverPhone" br></sa-item>
  53. <!-- <sa-item type="text" name="代理商" v-model="m.agent" br></sa-item>-->
  54. <sa-item type="text" name="代理商电话" v-model="m.agentPhone" br></sa-item>
  55. <sa-item type="text" name="运输车(车头牌)" v-model="m.chinaCarNo" placeholder="运输车车头牌,多个请用逗号隔开" br></sa-item>
  56. <sa-item type="text" name="运输车(车尾牌)" v-model="m.chinaCarSuff" placeholder="运输车车尾牌,多个请用逗号隔开"
  57. br></sa-item>
  58. <sa-item type="text" name="越南车车牌" v-model="m.carNo" br></sa-item>
  59. <sa-item type="text" name="海关报关单据" v-model="m.customProof" br></sa-item>
  60. <sa-item type="text" name="进口检验检疫证书" v-model="m.quarantineProof" br></sa-item>
  61. <sa-item type="text" name="商铺" v-model="m.shop" br></sa-item>
  62. <sa-item type="text" name="生产批号" v-model="m.productionCode" br></sa-item>
  63. <sa-item type="text" name="柜号" v-model="m.containerCode" br></sa-item>
  64. <sa-item name="" class="s-ok" br>
  65. <el-button type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
  66. </sa-item>
  67. </el-form>
  68. </div>
  69. </div>
  70. <!-- ------- 底部按钮 ------- -->
  71. <div class="s-foot">
  72. <el-button type="primary" @click="ok()">确定</el-button>
  73. <el-button @click="sa.closeCurrIframe()">取消</el-button>
  74. </div>
  75. </div>
  76. <script>
  77. var app = new Vue({
  78. components: {
  79. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue')
  80. },
  81. el: '.vue-box',
  82. data: {
  83. id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
  84. m: null, // 实体对象
  85. },
  86. methods: {
  87. // 创建一个 默认Model
  88. createModel: function () {
  89. return {
  90. id: '', // 主键
  91. businessId: '', // 业务id
  92. goodsName: '', // 产品学名
  93. grossWeight: '', // 毛重
  94. num: '', // 件数
  95. productionDate: '', // 生产日期
  96. expirationDate: '', // 保质期
  97. storageMode: '', // 储存条件
  98. productionMode: '', // 生产方式
  99. origin: '', // 原产国
  100. producerCode: '', // 进口冷链食品生产商注册号
  101. sendUnit: '', // 货主单位
  102. receiveUnit: '', // 收货单位
  103. route: '', // 货物流向
  104. driverName: '', // 司机姓名
  105. driverPhone: '', // 联系电话(司机)
  106. agent: '', // 代理商
  107. agentPhone: '', // 联系电话(代理人)
  108. chinaCarNo: '', // 运输车车牌
  109. chinaCarSuff: '',
  110. carNo: '', // 越南车车牌
  111. customProof: '', // 海关报关单据
  112. quarantineProof: '', // 进口检验检疫证书
  113. shop: '', // 商铺(互助组)
  114. productionCode: '', // 生产批号
  115. containerCode: '', // 柜号
  116. }
  117. },
  118. // 提交数据
  119. ok: function () {
  120. // 表单校验
  121. let m = this.m;
  122. sa.checkNull(m.goodsName, '请输入 [产品学名]');
  123. sa.checkNull(m.grossWeight, '请输入 [毛重]');
  124. sa.checkNull(m.num, '请输入 [数量]');
  125. sa.checkNull(m.productionDate, '请输入 [生产日期]');
  126. sa.checkNull(m.expirationDate, '请输入 [保质期]');
  127. sa.checkNull(m.storageMode, '请输入 [储存条件]');
  128. sa.checkNull(m.productionMode, '请输入 [生产方式]');
  129. sa.checkNull(m.origin, '请输入 [原产国]');
  130. sa.checkNull(m.producerCode, '请输入 [进口冷链食品生产商注册号]');
  131. sa.checkNull(m.sendUnit, '请输入 [货主单位]');
  132. sa.checkNull(m.receiveUnit, '请输入 [收货单位]');
  133. sa.checkNull(m.route, '请输入 [货物流向]');
  134. sa.checkNull(m.driverName, '请输入 [司机姓名]');
  135. sa.checkNull(m.driverPhone, '请输入 [司机联系电话]');
  136. // sa.checkNull(m.agent, '请输入 [代理商]');
  137. sa.checkNull(m.agentPhone, '请输入 [代理商联系电话]');
  138. if (!sa.isPhone(m.agentPhone)) {
  139. sa.error('代理商联系电话不正确')
  140. return;
  141. }
  142. sa.checkNull(m.chinaCarNo, '请输入 [运输车车头牌]');
  143. sa.checkNull(m.chinaCarSuff, '请输入 [运输车车尾牌]');
  144. sa.checkNull(m.carNo, '请输入 [越南车车牌]');
  145. sa.checkNull(m.customProof, '请输入 [海关报关单据]');
  146. sa.checkNull(m.quarantineProof, '请输入 [进口检验检疫证书]');
  147. // sa.checkNull(m.shop, '请输入 [商铺]');
  148. // sa.checkNull(m.productionCode, '请输入 [生产批号]');
  149. // sa.checkNull(m.containerCode, '请输入 [柜号]');
  150. // 开始增加或修改
  151. if (this.id <= 0) { // 添加
  152. sa.ajax('/TbDeclare/add', m, function (res) {
  153. sa.alert('增加成功', this.clean);
  154. }.bind(this));
  155. } else { // 修改
  156. sa.ajax('/TbDeclare/update', m, function (res) {
  157. sa.alert('修改成功', this.clean);
  158. }.bind(this));
  159. }
  160. },
  161. // 添加/修改 完成后的动作
  162. clean: function () {
  163. if (this.id == 0) {
  164. this.m = this.createModel();
  165. } else {
  166. parent.app.f5(); // 刷新父页面列表
  167. sa.closeCurrIframe(); // 关闭本页
  168. }
  169. }
  170. },
  171. mounted: function () {
  172. // 初始化数据
  173. if (this.id <= 0) {
  174. this.m = this.createModel();
  175. } else {
  176. sa.ajax('/TbDeclare/getById?id=' + this.id, function (res) {
  177. this.m = res.data;
  178. if (res.data == null) {
  179. sa.alert('未能查找到 id=' + this.id + " 详细数据");
  180. }
  181. }.bind(this))
  182. }
  183. }
  184. })
  185. </script>
  186. </body>
  187. </html>