tb-costomer-add.html 5.0 KB

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