阅行客电子档案
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.

344 lines
10 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
1 year ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <!-- 本地挂接 -->
  3. <el-dialog title="本地挂接" :close-on-click-modal="false" :modal-append-to-body="false" append-to-body :visible.sync="localHitchVisible" :before-close="handleCancel" @opened="opened">
  4. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  5. <el-form-item label="重复验证方式" prop="checkRepeatType">
  6. <el-select v-model="form.checkRepeatType" placeholder="请选择" style="width: 400px;">
  7. <el-option
  8. v-for="item in typeOptions"
  9. :key="item.value"
  10. :label="item.label"
  11. :value="item.value"
  12. />
  13. </el-select>
  14. </el-form-item>
  15. <el-form-item label="挂接字段" prop="hitchFiled">
  16. <el-select v-model="form.hitchFiled" placeholder="请选择" style="width: 400px;" @change="selectFiled">
  17. <el-option
  18. v-for="item in fieldOptions"
  19. :key="item.value"
  20. :label="item.label"
  21. :value="item.value"
  22. />
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item label="挂接详情" prop="fields">
  26. <div class="tag-wrapper">
  27. <el-tag v-for="item in hitchRemarkArray" :key="item" :closable="item !== '*'" @close="removeTag(item)">
  28. {{ item }}
  29. </el-tag>
  30. </div>
  31. <el-input v-model="form.fields" style="display: none;" type="hidden" />
  32. </el-form-item>
  33. <el-form-item label="匹配模式" prop="matchingMode">
  34. <el-select v-model="form.matchingMode" placeholder="请选择" style="width: 400px;" @change="changeMatchedType">
  35. <el-option
  36. v-for="item in matchedOptions"
  37. :key="item.value"
  38. :label="item.label"
  39. :value="item.value"
  40. />
  41. </el-select>
  42. </el-form-item>
  43. <el-form-item v-if="!connectionType" label="上传附件" prop="file">
  44. <div class="upload-bgColor">
  45. <input class="upload-input" type="file" accept=".zip" style="width: 110px; height: 32px;" @change="handleFile">
  46. <el-button size="small" type="primary"><i class="iconfont icon-shangchuan" />点击上传</el-button>
  47. </div>
  48. <!-- <div class="file-list">
  49. <i class="iconfont icon-xiaowenjian" />
  50. {{ form.file && form.file.name }}
  51. </div> -->
  52. <div v-for="item in fileList" :key="item.name" class="file-list">
  53. <i class="iconfont icon-xiaowenjian" />
  54. {{ item.name }}
  55. </div>
  56. <el-input v-show="false" v-model="form.file" />
  57. </el-form-item>
  58. <el-form-item v-if="connectionType" label="挂接类型" prop="batchType">
  59. <el-select v-model="form.batchType" placeholder="请选择" style="width: 400px;">
  60. <el-option
  61. v-for="item in batchTypeOptions"
  62. :key="item.value"
  63. :label="item.label"
  64. :value="item.value"
  65. />
  66. </el-select>
  67. </el-form-item>
  68. <el-form-item v-if="connectionType" label="文件路径" prop="filePath">
  69. <el-input v-model="form.filePath" style="width: 400px;" />
  70. </el-form-item>
  71. </el-form>
  72. <div slot="footer" class="dialog-footer">
  73. <el-button type="text" @click="handleCancel">取消</el-button>
  74. <el-button type="primary" @click.native="handleComfired">确定</el-button>
  75. </div>
  76. </el-dialog>
  77. </template>
  78. <script>
  79. import { crud } from '@crud/crud'
  80. import { FetchInitCategoryInputFieldByPid } from '@/api/system/category/category'
  81. import { batchMountUpload } from '@/utils/upload'
  82. import { mapGetters } from 'vuex'
  83. export default {
  84. name: 'LocalHitch',
  85. components: { },
  86. mixins: [crud()],
  87. props: {
  88. currentCategory: {
  89. type: Object,
  90. default: function() {
  91. return {}
  92. }
  93. }
  94. },
  95. data() {
  96. return {
  97. localHitchVisible: false,
  98. hitchRemarkArray: [],
  99. connectionType: 0,
  100. form: {
  101. checkRepeatType: null,
  102. hitchFiled: null,
  103. matchingMode: 1,
  104. fields: null,
  105. file: null,
  106. batchType: null,
  107. filePath: null
  108. },
  109. fileList: [],
  110. typeOptions: [
  111. {
  112. value: 1,
  113. label: '跳过'
  114. },
  115. {
  116. value: 2,
  117. label: '覆盖'
  118. },
  119. {
  120. value: 3,
  121. label: '追加'
  122. }
  123. ],
  124. matchedOptions: [
  125. {
  126. value: 1,
  127. label: '全量匹配'
  128. },
  129. {
  130. value: 2,
  131. label: '前缀模糊匹配'
  132. },
  133. {
  134. value: 3,
  135. label: '后缀模糊匹配'
  136. }
  137. ],
  138. batchTypeOptions: [
  139. {
  140. value: 1,
  141. label: '服务端挂接'
  142. },
  143. {
  144. value: 2,
  145. label: 'FTP挂接'
  146. },
  147. {
  148. value: 3,
  149. label: 'SFTP挂接'
  150. }
  151. ],
  152. fieldOptions: [],
  153. rules: {
  154. checkRepeatType: [
  155. { required: true, message: '请选择', trigger: 'change' }
  156. ],
  157. hitchFiled: [
  158. { required: true, message: '请选择', trigger: 'change' }
  159. ],
  160. fields: [
  161. { required: true, message: '请选择上面挂接字段生成挂接详情', trigger: 'blur' }
  162. ],
  163. matchingMode: [
  164. { required: true, message: '请选择', trigger: 'change' }
  165. ],
  166. batchType: [
  167. { required: true, message: '请选择', trigger: 'change' }
  168. ],
  169. filePath: [
  170. { required: true, message: '请选择', trigger: 'blur' }
  171. ]
  172. }
  173. }
  174. },
  175. computed: {
  176. ...mapGetters([
  177. 'baseApi'
  178. ]),
  179. collectLevel() {
  180. if (this.currentCategory.arrangeType === 1) {
  181. return 3
  182. } else if (this.currentCategory.arrangeType === 2) {
  183. return 2
  184. } else if (this.currentCategory.arrangeType === 3) {
  185. return 1
  186. }
  187. return null
  188. }
  189. },
  190. created() {
  191. },
  192. mounted() {
  193. },
  194. methods: {
  195. opened() {
  196. this.getFieldCommon()
  197. },
  198. handleFile(event) {
  199. const files = event.target.files
  200. for (let i = 0; i < files.length; i++) {
  201. this.fileList = []
  202. this.fileList.push(files[i])
  203. }
  204. },
  205. handleComfired() {
  206. if (this.fileList.length === 0) {
  207. this.$message({ message: '请先选择相关文件!', offset: 8 })
  208. return false
  209. }
  210. if (this.hitchRemarkArray.length === 1 && this.hitchRemarkArray[0] === '*') {
  211. this.form.fields = ''
  212. } else {
  213. this.form.fields = this.hitchRemarkArray.join('')
  214. }
  215. this.$refs['form'].validate((valid) => {
  216. if (valid) {
  217. let newhitchRemark = this.hitchRemarkArray.map(item => item.replace(/^\$|\$$|\*$/g, ''))
  218. newhitchRemark = newhitchRemark.filter(item => item !== '')
  219. const params = {
  220. 'categoryId': this.currentCategory.id,
  221. 'mountType': 1, // 挂接方式 1.本地挂接 2.远程挂接 3.上传目录 (目前只有1)
  222. 'checkRepeatType': this.form.checkRepeatType,
  223. 'matchingMode': this.form.matchingMode,
  224. 'fields': newhitchRemark
  225. }
  226. console.log(params)
  227. batchMountUpload(this.baseApi + '/api/collect/batchMount',
  228. this.fileList,
  229. params
  230. ).then(res => {
  231. if (res.data.code === 200) {
  232. this.$message({ message: '操作成功', type: 'success', offset: 8 })
  233. } else {
  234. this.$message({ message: '上传附件失败', type: 'error', offset: 8 })
  235. }
  236. this.handleCancel()
  237. this.crud.refresh()
  238. })
  239. } else {
  240. return false
  241. }
  242. })
  243. },
  244. getFieldCommon() {
  245. const params = {
  246. 'categoryId': this.currentCategory.id,
  247. 'categoryLevel': this.collectLevel
  248. }
  249. FetchInitCategoryInputFieldByPid(params).then(data => {
  250. this.fieldOptions = data.map((item, index) => {
  251. const json = {}
  252. json.id = item.id
  253. json.label = item.fieldCnName
  254. json.value = item.fieldName
  255. return json
  256. })
  257. })
  258. },
  259. selectFiled(val) {
  260. if (val) {
  261. if (this.hitchRemarkArray && this.hitchRemarkArray.includes('$' + val + '$')) {
  262. this.$message({ message: '请注意当前选择的挂接字段,在挂接详情内已存在!', offset: 8 })
  263. } else {
  264. const lastItemIndex = this.hitchRemarkArray.length - 1
  265. const index = this.hitchRemarkArray.indexOf('*')
  266. if (index !== -1) {
  267. if (index === lastItemIndex) {
  268. if (this.form.matchingMode === 2) {
  269. this.hitchRemarkArray.unshift('$' + val + '$')
  270. } else if (this.form.matchingMode === 3) {
  271. this.hitchRemarkArray.push('$' + val + '$')
  272. } else {
  273. this.hitchRemarkArray.splice(index > 0 ? index : 0, 0, '$' + val + '$')
  274. }
  275. } else {
  276. this.hitchRemarkArray.push('$' + val + '$')
  277. }
  278. } else {
  279. this.hitchRemarkArray.push('$' + val + '$')
  280. }
  281. }
  282. }
  283. },
  284. changeMatchedType(val) {
  285. const symbol = '*'
  286. const index = this.hitchRemarkArray.indexOf(symbol)
  287. if (index !== -1) {
  288. this.hitchRemarkArray.splice(index, 1)
  289. }
  290. if (val === 2) {
  291. this.hitchRemarkArray.push(symbol)
  292. } else if (val === 3) {
  293. this.hitchRemarkArray.unshift(symbol)
  294. }
  295. },
  296. removeTag(tag) {
  297. const index = this.hitchRemarkArray.indexOf(tag)
  298. if (index !== -1) {
  299. this.hitchRemarkArray.splice(index, 1)
  300. }
  301. },
  302. handleCancel() {
  303. this.$refs.form.resetFields()
  304. this.hitchRemarkArray = []
  305. this.fileList = []
  306. this.localHitchVisible = false
  307. }
  308. }
  309. }
  310. </script>
  311. <style lang='scss' scoped>
  312. ::v-deep .el-dialog{
  313. width: 585px !important;
  314. .el-dialog__body{
  315. padding: 30px 0 !important;
  316. }
  317. }
  318. .dialog-footer{
  319. margin-top: 0;
  320. }
  321. .file-list{
  322. width: 400px;
  323. font-size: 12px;
  324. color: #A6ADB6;
  325. }
  326. .tag-wrapper{
  327. display: flex;
  328. justify-content: flex-start;
  329. flex-wrap: wrap;
  330. width: 400px;
  331. min-height: 32px;
  332. padding: 0 10px;
  333. border-radius: 3px;
  334. border: 1px solid #e6e8ed;
  335. .el-tag{
  336. margin-right: 6px;
  337. }
  338. }
  339. </style>