importPatent.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <div class="import-patent">
  3. <el-container class="import-patent">
  4. <el-aside class="import-patent-main" style="width:450px">
  5. <el-container class="import-patent-action">
  6. <el-main class="import-patent-action-main" v-loading="loading">
  7. <el-form :model="form" >
  8. <el-form-item label="数据来源:">
  9. <select style="width:300px;border:0;outline:none" name="" id="" v-model="sourceId">
  10. <option value="">请选择数据来源</option>
  11. <option v-for="item in customField.dataType" :value="item.id">{{item.name}}</option>
  12. </select>
  13. <el-divider ></el-divider>
  14. </el-form-item>
  15. <el-form-item label="选择需要上传的专利信息导入文件">
  16. <el-upload class="upload-file" drag action="#" :auto-upload="false" :show-file-list="false" :on-change="onChange">
  17. <i :class="!form.file ? 'el-icon-upload' : 'el-icon-refresh'"></i>
  18. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  19. <div class="el-upload__tip" slot="tip"></div>
  20. </el-upload>
  21. </el-form-item>
  22. </el-form>
  23. </el-main>
  24. </el-container>
  25. </el-aside>
  26. <el-main>
  27. <systemTask ref="systemTask" :form="1" :reportId="reportId" :productId="productId" :projectId="projectId"></systemTask>
  28. </el-main>
  29. </el-container>
  30. </div>
  31. </template>
  32. <script>
  33. // import systemTask from './systemTask.vue'
  34. import systemTask from '@/views/task/index.vue'
  35. export default {
  36. props:['reportId','asCompare','productId','projectId'],
  37. components: {
  38. systemTask
  39. },
  40. data() {
  41. return {
  42. form: {},
  43. sourceId: '',
  44. customField: [],
  45. loading:false,
  46. }
  47. },
  48. computed: {},
  49. mounted() {
  50. this.getCustomField()
  51. },
  52. methods: {
  53. getCustomField() {
  54. this.$api.getCustomField({ projectId: 0, patentTotal: false }).then(response => {
  55. this.customField = response.data
  56. })
  57. },
  58. getQueueList() {
  59. this.$refs.systemTask.getQueueList()
  60. },
  61. onChange(file, fileList) {
  62. this.form.file = file.raw
  63. this.handleConfirm()
  64. },
  65. handleConfirm() {
  66. const json = JSON.parse(JSON.stringify(this.form))
  67. const refs = this.$refs
  68. let data = {
  69. reportId: this.reportId,
  70. productId: this.productId,
  71. projectId: this.projectId,
  72. sourceId:this.sourceId,
  73. fieldList: [],
  74. folderIds: refs.folderTree ? refs.folderTree.getCheckedKeys() : [],
  75. asCompare:this.asCompare
  76. }
  77. for (let uid in json.field) {
  78. const field = json.field[uid]
  79. if (!field) {
  80. continue;
  81. }
  82. const type = field.type
  83. const value = field.value
  84. if (value) {
  85. if (type === 5) {
  86. value.map(option => {
  87. data.fieldList.push({
  88. fieldId: parseInt(id),
  89. type: type,
  90. optionId: option
  91. })
  92. })
  93. } else if (type === 6) {
  94. const tree = refs[id]
  95. if (tree) {
  96. const treeNode = tree[0].getCheckedKeys()
  97. treeNode.map(node => {
  98. data.fieldList.push({
  99. fieldId: parseInt(id),
  100. type: type,
  101. optionId: node
  102. })
  103. })
  104. }
  105. } else {
  106. data.fieldList.push({
  107. fieldId: parseInt(id),
  108. type: type,
  109. optionId: [0, 1, 2].indexOf(type) === -1 ? value : 0,
  110. text: value
  111. })
  112. }
  113. }
  114. }
  115. if (!this.form.file) {
  116. this.$message.error('请选择文件')
  117. return false
  118. }
  119. if (!this.sourceId) {
  120. this.$message.error('请选择数据类型')
  121. return false
  122. }
  123. let formData = new FormData()
  124. formData.append('file', this.form.file)
  125. formData.append('json', JSON.stringify(data))
  126. this.btnLoading = true
  127. this.loading = true
  128. // console.log(formData)
  129. this.$api.importProjectPatent(formData).then(response => {
  130. this.$message.success('任务创建成功')
  131. this.form.file = null
  132. this.btnLoading = false
  133. this.loading = false
  134. // this.handleClose()
  135. this.getQueueList()
  136. }).catch(error => {
  137. this.btnLoading = false
  138. this.loading = false
  139. })
  140. }
  141. },
  142. }
  143. </script>
  144. <style lang="scss">
  145. .el-divider--horizontal{
  146. margin:0
  147. }
  148. .import-patent {
  149. height: 100%;
  150. .import-patent-main {
  151. overflow-x: hidden;
  152. padding: 0;
  153. height: 100%;
  154. background: #fff;
  155. }
  156. .import-patent-action {
  157. width: 450px;
  158. height: 100%;
  159. border-right: 1px solid #d2d2d2;
  160. float: left;
  161. .custom-field-form .el-form-item__label {
  162. font-weight: bold !important;
  163. }
  164. .import-patent-action-form {
  165. margin-left: 20px;
  166. }
  167. .import-patent-action-main {
  168. padding: 10px;
  169. }
  170. }
  171. .import-patent-button {
  172. height: 70px !important;
  173. text-align: right;
  174. }
  175. }
  176. </style>