Info.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <div class="hello">
  3. <el-form status-icon label-width="100px" class="infoForm" v-model="infoForm">
  4. <el-form-item :label="$t('item_name')+':'" >
  5. <el-input type="text" auto-complete="off" v-model="infoForm.item_name" placeholder="" ></el-input>
  6. </el-form-item>
  7. <el-form-item :label="$t('item_description')+':'" >
  8. <el-input type="text" auto-complete="off" v-model="infoForm.item_description" placeholder="" ></el-input>
  9. </el-form-item>
  10. <el-form-item label="" >
  11. <el-radio v-model="isOpenItem" :label="true">{{$t('Open_item')}}</el-radio>
  12. <el-radio v-model="isOpenItem" :label="false">{{$t('private_item')}}</el-radio>
  13. </el-form-item>
  14. <el-form-item :label="$t('visit_password')+':'" v-show="!isOpenItem">
  15. <el-input type="password" auto-complete="off" v-model="infoForm.password"></el-input>
  16. </el-form-item>
  17. <el-form-item label="" >
  18. <el-button type="primary" style="width:100%;" @click="FormSubmit" >{{$t('submit')}}</el-button>
  19. </el-form-item>
  20. </el-form>
  21. </div>
  22. </template>
  23. <script>
  24. export default {
  25. name: 'Login',
  26. components : {
  27. },
  28. data () {
  29. return {
  30. infoForm:{
  31. },
  32. isOpenItem:true,
  33. }
  34. },
  35. methods: {
  36. get_item_info(){
  37. var that = this ;
  38. var url = DocConfig.server+'/api/item/detail';
  39. var params = new URLSearchParams();
  40. params.append('item_id', that.$route.params.item_id);
  41. that.axios.post(url, params)
  42. .then(function (response) {
  43. if (response.data.error_code === 0 ) {
  44. var Info = response.data.data
  45. if (Info.password) {
  46. that.isOpenItem = false;
  47. };
  48. that.infoForm = Info;
  49. }else{
  50. that.$alert(response.data.error_message);
  51. }
  52. })
  53. .catch(function (error) {
  54. console.log(error);
  55. });
  56. },
  57. FormSubmit() {
  58. var that = this ;
  59. var url = DocConfig.server+'/api/item/update';
  60. if (!this.isOpenItem && !this.infoForm.password) {
  61. that.$alert(that.$t("private_item_passwrod"));
  62. return false;
  63. };
  64. if (this.isOpenItem) {
  65. this.infoForm.password = '';
  66. };
  67. var params = new URLSearchParams();
  68. params.append('item_id', that.$route.params.item_id);
  69. params.append('item_name', this.infoForm.item_name);
  70. params.append('item_description', this.infoForm.item_description);
  71. params.append('item_domain', this.infoForm.item_domain);
  72. params.append('password', this.infoForm.password);
  73. that.axios.post(url, params)
  74. .then(function (response) {
  75. if (response.data.error_code === 0 ) {
  76. that.$message.success(that.$t("modify_success"));
  77. }else{
  78. that.$alert(response.data.error_message);
  79. }
  80. })
  81. .catch(function (error) {
  82. console.log(error);
  83. });
  84. },
  85. },
  86. mounted(){
  87. this.get_item_info();
  88. }
  89. }
  90. </script>
  91. <!-- Add "scoped" attribute to limit CSS to this component only -->
  92. <style scoped>
  93. .center-card a {
  94. font-size: 12px;
  95. }
  96. .center-card{
  97. text-align: center;
  98. width: 600px;
  99. height: 500px;
  100. }
  101. .infoForm{
  102. width:350px;
  103. margin-left: 60px;
  104. margin-top: 30px;
  105. }
  106. .goback-btn{
  107. z-index: 999;
  108. margin-left: 500px;
  109. }
  110. </style>