tb-costomer-add.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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 .el-input,
  23. .c-panel .el-form .el-textarea__inner {
  24. width: 250px;
  25. }
  26. </style>
  27. </head>
  28. <body>
  29. <div class="vue-box" :class="{sbot: id}" style="display: none;" :style="'display: block;'">
  30. <!-- ------- 内容部分 ------- -->
  31. <div class="s-body">
  32. <div class="c-panel">
  33. <div class="c-title" v-if="id == 0">数据添加</div>
  34. <div class="c-title" v-else>数据修改</div>
  35. <el-form v-if="m">
  36. <el-row>
  37. <sa-item type="text" name="企业名称" v-model="m.name" placeholder="请输入企业名称" br></sa-item>
  38. <sa-item type="text" name="联系人" v-model="m.dutyPeople" placeholder="请输入联系人" br></sa-item>
  39. <sa-item type="text" name="联系电话" v-model="m.phone" placeholder="请输入联系号码" br></sa-item>
  40. <div class="c-item">
  41. <label class="c-label">结算类型:</label>
  42. <el-radio-group v-model="m.payType">
  43. <el-radio :label="1" :disabled="currentCustomerId!=='1'">现结</el-radio>
  44. <el-radio :label="2" :disabled="currentCustomerId!=='1'">月结</el-radio>
  45. </el-radio-group>
  46. </div>
  47. <sa-item type="img" name="营业执照" v-model="m.businessLicence" br></sa-item>
  48. </el-row>
  49. <sa-item name="" class="s-ok" br>
  50. <el-button type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
  51. </sa-item>
  52. </el-form>
  53. </div>
  54. </div>
  55. <!-- ------- 底部按钮 ------- -->
  56. <div class="s-foot">
  57. <el-button type="primary" @click="ok()">确定</el-button>
  58. <el-button @click="sa.closeCurrIframe()">取消</el-button>
  59. </div>
  60. </div>
  61. <script>
  62. var app = new Vue({
  63. components: {
  64. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue')
  65. },
  66. el: '.vue-box',
  67. data: {
  68. id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
  69. m: null, // 实体对象
  70. options: [],
  71. currentCustomerId: '1',
  72. },
  73. methods: {
  74. getCurrendCustomer() {
  75. sa.ajax('/TbCostomer/getCurrentCustomerId', function(resp) {
  76. this.currentCustomerId = resp.data;
  77. }.bind(this));
  78. },
  79. // 创建一个 默认Model
  80. createModel: function() {
  81. return {
  82. name: '', // 名称
  83. phone: '', // 联系号码
  84. dutyPeople: '', // 负责人
  85. addressIds: '', // 地址id
  86. addressStr: '', // 地址
  87. businessLicence: '', // 营业执照
  88. address_arry: [],
  89. payType: 1,
  90. status: '1', // 状态(0=否,1=是)
  91. judgeStatus: '2', // 审核状态(1=未审核,2审核通过,3审核不通过)
  92. }
  93. },
  94. // 提交数据
  95. ok: function() {
  96. // 表单校验
  97. let m = this.m;
  98. sa.checkNull(m.name, '请输入 [企业名称]');
  99. if (!sa.isPhone(m.phone)) {
  100. sa.error('联系号码不正确')
  101. return;
  102. }
  103. sa.checkNull(m.dutyPeople, '请输入 [联系人]');
  104. // this.m.addressIds = this.m.address_arry.join(',');
  105. // sa.checkNull(m.addressIds, '请选择 [地址信息]');
  106. // 开始增加或修改
  107. if (this.id <= 0) { // 添加
  108. sa.ajax('/TbCostomer/add', m, function(res) {
  109. sa.alert('增加成功', this.clean);
  110. }.bind(this));
  111. } else { // 修改
  112. sa.ajax('/TbCostomer/update', m, function(res) {
  113. sa.alert('修改成功', this.clean);
  114. }.bind(this));
  115. }
  116. },
  117. // 添加/修改 完成后的动作
  118. clean: function() {
  119. if (this.id == 0) {
  120. this.m = this.createModel();
  121. } else {
  122. parent.app.f5(); // 刷新父页面列表
  123. sa.closeCurrIframe(); // 关闭本页
  124. }
  125. }
  126. },
  127. mounted: function() {
  128. this.getCurrendCustomer()
  129. // 初始化数据
  130. if (this.id <= 0) {
  131. this.m = this.createModel();
  132. } else {
  133. sa.ajax('/TbCostomer/getById?id=' + this.id, function(res) {
  134. this.m = res.data;
  135. this.m.address_arry = res.data ? res.data.addressIds.split(",").map(id =>
  136. parseInt(id)) : [];
  137. if (res.data == null) {
  138. sa.alert('未能查找到 id=' + this.id + " 详细数据");
  139. }
  140. }.bind(this))
  141. }
  142. }
  143. })
  144. </script>
  145. </body>
  146. </html>