bc0d78703c9c144d3049ba53484967f5f354f9bf.svn-base 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <template>
  2. <a-spin :spinning="confirmLoading">
  3. <j-form-container :disabled="formDisabled">
  4. <a-form-model ref="form" :model="model" slot="detail" :rules="validatorRules">
  5. <a-row>
  6. <a-col :span="24">
  7. <a-form-model-item label="租户名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
  8. <a-input v-model="model.name" placeholder="请输入租户名称"></a-input>
  9. </a-form-model-item>
  10. </a-col>
  11. <a-col :span="24">
  12. <a-form-model-item label="租户编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="id">
  13. <a-input style="width: 100%" :min="1" v-model="model.id" placeholder="请输入租户编号" :disabled="disabledId"></a-input>
  14. </a-form-model-item>
  15. </a-col>
  16. <a-col :span="24">
  17. <a-form-model-item label="开始时间" :labelCol="labelCol" :wrapperCol="wrapperCol">
  18. <j-date placeholder="请选择开始时间" v-model="model.beginDate" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%"/>
  19. </a-form-model-item>
  20. </a-col>
  21. <a-col :span="24">
  22. <a-form-model-item label="结束时间" :labelCol="labelCol" :wrapperCol="wrapperCol">
  23. <j-date placeholder="请选择结束时间" v-model="model.endDate" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%"/>
  24. </a-form-model-item>
  25. </a-col>
  26. <a-col :span="24">
  27. <a-form-model-item label="状态" :labelCol="labelCol" :wrapperCol="wrapperCol">
  28. <a-radio-group name="tenantStatus" v-model="model.status">
  29. <a-radio :value="1">正常</a-radio>
  30. <a-radio :value="0">冻结</a-radio>
  31. </a-radio-group>
  32. </a-form-model-item>
  33. </a-col>
  34. <a-col v-if="showFlowSubmitButton" :span="24" style="text-align: center">
  35. <a-button @click="submitForm">提 交</a-button>
  36. </a-col>
  37. </a-row>
  38. </a-form-model>
  39. </j-form-container>
  40. </a-spin>
  41. </template>
  42. <script>
  43. import { httpAction, getAction } from '@/api/manage'
  44. import { validateDuplicateValue } from '@/utils/util'
  45. import JFormContainer from '@/components/jeecg/JFormContainer'
  46. import JDate from '@/components/jeecg/JDate'
  47. import JDictSelectTag from "@/components/dict/JDictSelectTag"
  48. export default {
  49. name: "TenantForm",
  50. components: {
  51. JFormContainer,
  52. JDate,
  53. JDictSelectTag,
  54. },
  55. props: {
  56. formData: {
  57. type: Object,
  58. default: ()=>{},
  59. required: false
  60. },
  61. normal: {
  62. type: Boolean,
  63. default: false,
  64. required: false
  65. },
  66. disabled: {
  67. type: Boolean,
  68. default: false,
  69. required: false
  70. }
  71. },
  72. data () {
  73. return {
  74. model: {status:1},
  75. id:'',
  76. labelCol: {
  77. xs: { span: 24 },
  78. sm: { span: 5 },
  79. },
  80. wrapperCol: {
  81. xs: { span: 24 },
  82. sm: { span: 16 },
  83. },
  84. confirmLoading: false,
  85. validatorRules: {
  86. id:[ { required: true, message: '请输入租户编号!' },]
  87. },
  88. url: {
  89. add: "/sys/tenant/add",
  90. edit: "/sys/tenant/edit",
  91. queryById: "/sys/tenant/queryById"
  92. }
  93. }
  94. },
  95. computed: {
  96. formDisabled(){
  97. if(this.normal===false){
  98. if(this.formData.disabled===false){
  99. return false
  100. }else{
  101. return true
  102. }
  103. }
  104. return this.disabled
  105. },
  106. disabledId(){
  107. return this.id?true : false;
  108. },
  109. showFlowSubmitButton(){
  110. if(this.normal===false){
  111. if(this.formData.disabled===false){
  112. return true
  113. }else{
  114. return false
  115. }
  116. }else{
  117. return false
  118. }
  119. }
  120. },
  121. created () {
  122. this.showFlowData();
  123. },
  124. methods: {
  125. show (record) {
  126. this.model = record?Object.assign({}, record):this.model;
  127. this.id = record?record.id:'';
  128. this.visible = true;
  129. },
  130. showFlowData(){
  131. if(this.normal === false){
  132. let params = {id:this.formData.dataId};
  133. getAction(this.url.queryById,params).then((res)=>{
  134. if(res.success){
  135. this.edit (res.result);
  136. }
  137. });
  138. }
  139. },
  140. submitForm () {
  141. const that = this;
  142. // 触发表单验证
  143. that.$refs.form.validate(valid => {
  144. if (valid) {
  145. that.confirmLoading = true;
  146. let httpurl = '';
  147. let method = '';
  148. if(!this.id){
  149. httpurl+=this.url.add;
  150. method = 'post';
  151. }else{
  152. httpurl+=this.url.edit;
  153. //method = 'put';
  154. method = 'post';
  155. }
  156. httpAction(httpurl,this.model,method).then((res)=>{
  157. if(res.success){
  158. that.$message.success(res.message);
  159. that.$emit('ok');
  160. }else{
  161. if("该编号已存在!" == res.message){
  162. this.model.id=""
  163. }
  164. that.$message.warning(res.message);
  165. }
  166. }).finally(() => {
  167. that.confirmLoading = false;
  168. })
  169. }else{
  170. return false;
  171. }
  172. })
  173. },
  174. popupCallback(row){
  175. this.model = Object.assign(this.model, row);
  176. },
  177. }
  178. }
  179. </script>