You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

181 lines
7.1 KiB

  1. <template>
  2. <section>
  3. <el-row ref="table">
  4. <!--编辑界面 Branch 管理端机构表机构下面若干部门-->
  5. <el-form :model="editForm" label-width="120px" :rules="editFormRules" ref="editFormRef">
  6. <el-form-item label="机构编号" prop="id" v-if="opType==='add'">
  7. <el-input v-model="editForm.id" placeholder="机构编号,如果不填写将后台自动生成" :maxlength="50" :disabled="branch.id"></el-input>
  8. <br><font color="red">机构号将作为该机构的管理员登录账号</font>
  9. </el-form-item>
  10. <el-form-item label="机构名称" prop="branchName">
  11. <el-input v-model="editForm.branchName" placeholder="机构名称" :maxlength="50">
  12. <template slot="prepend" v-if="opType==='edit'">
  13. {{editForm.id}}
  14. </template>
  15. </el-input>
  16. </el-form-item>
  17. <el-form-item label="是否可用" prop="enabled" v-if="opType==='edit'">
  18. <el-select v-model="editForm.enabled">
  19. <el-option v-for="(item,index) in dicts['enabled']" :value="item.id" :label="item.name" :key="index"></el-option>
  20. </el-select>
  21. </el-form-item>
  22. <el-form-item label="行业分类" prop="industryCategory">
  23. <el-select v-model="editForm.industryCategory">
  24. <el-option v-for="(item,index) in dicts['industryCategory']" :value="item.id" :label="item.name" :key="index"></el-option>
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item label="创建日期" prop="cdate" v-if="opType==='edit'">
  28. <el-date-picker type="date" placeholder="选择日期" v-model="editForm.cdate" value-format="yyyy-MM-dd HH:mm:ss" format="yyyy-MM-dd"></el-date-picker>
  29. </el-form-item>
  30. <el-form-item label="联系人姓名" prop="lusername">
  31. <el-input v-model="editForm.lusername" placeholder="联系人姓名" :maxlength="255"></el-input>
  32. </el-form-item>
  33. <el-form-item label="联系电话" prop="lphoneNo">
  34. <el-input v-model="editForm.lphoneNo" placeholder="联系电话" :maxlength="50"></el-input>
  35. </el-form-item>
  36. <el-form-item label="联系邮箱" prop="emaill">
  37. <el-input v-model="editForm.emaill" placeholder="联系邮箱" :maxlength="50"></el-input>
  38. </el-form-item>
  39. <el-form-item label="管理员" prop="admUserid">
  40. 账号:&nbsp;<font style="font-size:10px;">{{editForm.admUserid}}</font> &nbsp; &nbsp;名称&nbsp; <font style="font-size:10px;">{{editForm.admUsername}} </font>&nbsp;登录密码<font style="font-size:10px;">{{opType==='add'?'888888':'*****'}}</font>
  41. <br><font color="blue">管理员账户具有最高权限仅作为内部管理权限使用账户编号与机构号相同不可修改</font>
  42. </el-form-item>
  43. <el-form-item label="公司地址" prop="address" v-if="opType==='edit'">
  44. <el-input v-model="editForm.address" placeholder="公司地址" :maxlength="255"></el-input>
  45. </el-form-item>
  46. </el-form>
  47. </el-row>
  48. <el-row>
  49. <el-button @click.native="handleCancel">取消</el-button>
  50. <el-button v-loading="load.edit" type="primary" @click.native="saveSubmit" :disabled="load.edit==true">提交</el-button>
  51. </el-row>
  52. </section>
  53. </template>
  54. <script>
  55. import util from '@/common/js/util';//全局公共库
  56. import config from "@/common/config"; //全局公共库import
  57. import { initDicts, addBranch,editBranch } from '@/api/mdp/sys/branch';
  58. import { mapGetters } from 'vuex'
  59. export default {
  60. name:'branchEdit',
  61. components: {
  62. },
  63. computed: {
  64. ...mapGetters([ 'userInfo' ]),
  65. },
  66. props:['branch','visible','opType'],
  67. watch: {
  68. 'branch':function( branch ) {
  69. if(branch){
  70. this.editForm = {...branch};
  71. }
  72. },
  73. 'editForm.id':function( val ) {
  74. this.editForm.admUserid =val;
  75. },
  76. 'editForm.branchName':function( val ) {
  77. this.editForm.admUsername =val+'管理员';
  78. },
  79. 'visible':function(visible) {
  80. if(visible==true){
  81. this.initData()
  82. }
  83. }
  84. },
  85. data() {
  86. return {
  87. currOpType:'add',//add/edit
  88. load:{ list: false, edit: false, del: false, add: false },//查询中...
  89. dicts:{
  90. industryCategory:[],
  91. enabled:[],
  92. },//下拉选择框的所有静态数据 params={categoryId:'all',itemCodes:['sex']} 返回结果 {sex: [{id:'1',name:'男'},{id:'2',name:'女'}]}
  93. editFormRules: {
  94. branchName: [
  95. { required: true, message: '机构名称不能为空', trigger: 'blur' }
  96. ]
  97. },
  98. editForm: {
  99. id:'',branchName:'',enabled:'',industryCategory:'',cuserid:'',cdate:'',cusername:'',lphoneNo:'',emaill:'',bizProcInstId:'',bizFlowState:'',pbranchId:'',admUserid:'',admUsername:'',lusername:'',luserid:'',address:''
  100. },
  101. maxTableHeight:300,
  102. }//end return
  103. },//end data
  104. methods: {
  105. ...util,
  106. // 取消按钮点击 父组件监听@cancel="editFormVisible=false" 监听
  107. handleCancel:function(){
  108. this.$refs['editFormRef'].resetFields();
  109. this.$emit('cancel');
  110. },
  111. //新增、编辑提交Branch 管理端机构表(机构下面若干部门)父组件监听@submit="afterEditSubmit"
  112. saveSubmit: function () {
  113. this.$refs.editFormRef.validate((valid) => {
  114. if (valid) {
  115. this.$confirm('确认提交吗?', '提示', {}).then(() => {
  116. this.load.edit=true
  117. let params = Object.assign({}, this.editForm);
  118. var func=addBranch
  119. if(this.currOpType=='edit'){
  120. func=editBranch
  121. }
  122. func(params).then((res) => {
  123. this.load.edit=false
  124. var tips=res.data.tips;
  125. if(tips.isOk){
  126. this.editForm=res.data.data
  127. this.initData()
  128. this.currOpType="edit";
  129. this.$emit('submit');// @submit="afterAddSubmit"
  130. }
  131. this.$notify({ position:'bottom-left',showClose:true, message: tips.msg, type: tips.isOk?'success':'error' });
  132. }).catch( err =>this.load.edit=false);
  133. });
  134. }else{
  135. this.$notify({ showClose:true, message: "表单验证不通过,请修改表单数据再提交", type: 'error' });
  136. }
  137. });
  138. },
  139. initData: function(){
  140. this.currOpType=this.opType
  141. if(this.branch){
  142. this.editForm = Object.assign({},this.branch);
  143. }
  144. if(this.opType=='edit'){
  145. }else{
  146. this.editForm.cuserid=this.userInfo.userid
  147. this.editForm.cusername=this.userInfo.username
  148. this.editForm.luserid=this.userInfo.userid
  149. this.editForm.lusername=this.userInfo.username
  150. this.editForm.lphoneNo=this.userInfo.phoneno
  151. this.editForm.email=this.userInfo.email
  152. this.editForm.enabled="0"
  153. }
  154. },
  155. },//end method
  156. mounted() {
  157. this.$nextTick(() => {
  158. initDicts(this);
  159. this.initData()
  160. this.maxTableHeight = util.calcTableMaxHeight(this.$refs.table.$el)
  161. });
  162. }
  163. }
  164. </script>
  165. <style scoped>
  166. </style>