Copy.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <div class="hello">
  3. <p class="tips">{{$t('copy_item_tips1')}}</p>
  4. <el-form status-icon label-width="10px" class="infoForm" v-model="infoForm">
  5. <el-form-item label class="text-left">
  6. <el-select
  7. style="width:100%;"
  8. v-model="copy_item_id"
  9. :placeholder="$t('please_choose')"
  10. @change="choose_copy_item"
  11. >
  12. <el-option
  13. v-for="item in itemList"
  14. :key="item.item_id"
  15. :label="item.item_name"
  16. :value="item.item_id"
  17. ></el-option>
  18. </el-select>
  19. </el-form-item>
  20. <el-form-item>
  21. <el-tooltip class="item" effect="dark" :content="$t('copy_item_tips2')" placement="right">
  22. <el-input
  23. type="text"
  24. auto-complete="off"
  25. v-model="item_name"
  26. :placeholder="$t('copy_item_tips2')"
  27. ></el-input>
  28. </el-tooltip>
  29. </el-form-item>
  30. <el-form-item label>
  31. <el-button type="primary" style="width:100%;" @click="FormSubmit">{{$t('submit')}}</el-button>
  32. </el-form-item>
  33. </el-form>
  34. </div>
  35. </template>
  36. <script>
  37. export default {
  38. name: 'Login',
  39. components: {},
  40. data() {
  41. return {
  42. infoForm: {},
  43. isOpenItem: true,
  44. itemList: {},
  45. copy_item_id: '',
  46. item_name: '',
  47. item_description: ''
  48. }
  49. },
  50. methods: {
  51. get_item_list() {
  52. var that = this
  53. var url = DocConfig.server + '/api/item/myList'
  54. var params = new URLSearchParams()
  55. that.axios.get(url, params).then(function(response) {
  56. if (response.data.error_code === 0) {
  57. // that.$message.success("加载成功");
  58. var json = response.data.data
  59. that.itemList = json
  60. } else {
  61. that.$alert(response.data.error_message)
  62. }
  63. })
  64. },
  65. choose_copy_item(item_id) {
  66. for (var i = 0; i < this.itemList.length; i++) {
  67. if (item_id == this.itemList[i].item_id) {
  68. this.item_name = this.itemList[i].item_name + '--copy'
  69. this.item_description = this.itemList[i].item_description
  70. }
  71. }
  72. },
  73. FormSubmit() {
  74. var that = this
  75. var url = DocConfig.server + '/api/item/add'
  76. if (!this.isOpenItem && !this.infoForm.password) {
  77. that.$alert(that.$t('private_item_passwrod'))
  78. return false
  79. }
  80. if (this.isOpenItem) {
  81. this.infoForm.password = ''
  82. }
  83. var params = new URLSearchParams()
  84. params.append('copy_item_id', this.copy_item_id)
  85. params.append('item_name', this.item_name)
  86. params.append('item_description', this.item_description)
  87. that.axios.post(url, params).then(function(response) {
  88. if (response.data.error_code === 0) {
  89. that.$router.push({ path: '/item/index' })
  90. } else {
  91. that.$alert(response.data.error_message)
  92. }
  93. })
  94. }
  95. },
  96. mounted() {
  97. this.get_item_list()
  98. }
  99. }
  100. </script>
  101. <!-- Add "scoped" attribute to limit CSS to this component only -->
  102. <style scoped>
  103. .center-card a {
  104. font-size: 12px;
  105. }
  106. .infoForm {
  107. width: 380px;
  108. margin-top: 50px;
  109. }
  110. .tips {
  111. margin-left: 10px;
  112. color: #9ea1a6;
  113. }
  114. </style>