PatentBatchIndex.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <template>
  2. <div>
  3. <el-dialog title="批量标引" :visible.sync="visible" width="500px" append-to-body destroy-on-close :before-close="close" :close-on-click-modal="false">
  4. <el-container class="patent-batch-index">
  5. <el-main class="patent-batch-index-main">
  6. <el-form>
  7. <el-form-item v-for="(item, index) in field" :key="index">
  8. <div slot="label">
  9. <span>{{ index + 1 }}. {{ item.name }}</span>
  10. </div>
  11. <el-switch class="patent-batch-index-field-enabled" v-model="item.enabled"
  12. @change="change(item)"></el-switch>
  13. <div v-if="item.enabled" class="patent-batch-index-field-content">
  14. <template v-if="item.type === 0 || item.type === 2">
  15. <el-input type="textarea" v-model="item.text" @change="changeOption(item)" placeholder="请输入内容"
  16. size="small"></el-input>
  17. </template>
  18. <template v-if="item.type === 1">
  19. <el-date-picker v-model="item.text" @change="changeOption(item)" value-format="yyyy-MM-dd" type="date"
  20. size="small" placeholder="选择日期" class="width_100"></el-date-picker>
  21. </template>
  22. <!-- <template v-if="item.type === 4">
  23. <el-radio-group v-model="item.selected" @change="changeOption(item)">
  24. <div v-for="option in item.option" :key="option.id">
  25. <el-radio :label="option.id">{{ option.name }}</el-radio>
  26. </div>
  27. </el-radio-group>
  28. </template> -->
  29. <template v-if="item.type === 5 || item.type === 4">
  30. <el-checkbox-group v-model="item.selected" @change="changeOption(item)">
  31. <div v-for="option in item.option" :key="option.id">
  32. <el-checkbox :label="option.id">{{ option.name }}</el-checkbox>
  33. </div>
  34. </el-checkbox-group>
  35. </template>
  36. <template v-if="item.type === 6">
  37. <el-tree :ref="item.id" :data="item.option" node-key="id"
  38. check-strictly default-expand-all :props="{ children: 'child', label: 'name' }">
  39. <span class="custom-tree-node" slot-scope="{ node, data }">
  40. <el-checkbox-group v-model="item.selected" @change="changeOption(item)">
  41. <el-checkbox :label="data.id">{{ data.name }}</el-checkbox>
  42. </el-checkbox-group>
  43. </span>
  44. </el-tree>
  45. </template>
  46. <template v-if="item.isCategory == 1">
  47. <el-tree :ref="item.id" :data="item.option" node-key="id"
  48. check-strictly default-expand-all :props="{ children: 'child', label: 'name' }">
  49. <span class="custom-tree-node" slot-scope="{ node, data }">
  50. <el-checkbox-group v-model="item.selected" @change="changeOption(item)">
  51. <el-checkbox :label="data.id">{{ data.name }}</el-checkbox>
  52. </el-checkbox-group>
  53. </span>
  54. </el-tree>
  55. </template>
  56. </div>
  57. </el-form-item>
  58. </el-form>
  59. </el-main>
  60. </el-container>
  61. <div slot="footer" class="dialog-footer">
  62. <el-button @click="close">取 消</el-button>
  63. <el-button type="primary" @click="submit">确 定</el-button>
  64. </div>
  65. </el-dialog>
  66. </div>
  67. </template>
  68. <script>
  69. export default {
  70. props: ['projectId'],
  71. data() {
  72. return {
  73. // 控制弹窗的显示
  74. visible: false,
  75. // 自定义及架构数据源
  76. field: [],
  77. // 选择的数据
  78. selectQuery: {},
  79. // 检索的数据
  80. searchQuery: '',
  81. // 自定义字段筛选的数据
  82. customFields: [],
  83. // 自定义字段选中或填写的值
  84. selectValue: [],
  85. }
  86. },
  87. mounted() {
  88. },
  89. methods: {
  90. //
  91. changeOption(val) {
  92. // console.log(val);
  93. var obj = {
  94. projectId: this.projectId,
  95. fieldType: val.type,
  96. fieldId: val.id,
  97. optionType: 2,//操作类型 0取消 1增加 2覆盖
  98. }
  99. if ([0, 1, 2].includes(val.type)) {
  100. obj.fieldValue = val.text ? [val.text] : null
  101. } else {
  102. obj.fieldValue = val.selected
  103. }
  104. this.findSplice(val,obj)
  105. },
  106. findSplice(val,obj) {
  107. let a = this.selectValue.findIndex(item => {
  108. return item.fieldId == val.id
  109. })
  110. if (a != -1) {
  111. if (!obj.fieldValue || obj.fieldValue.length == 0) {
  112. this.selectValue.splice(a, 1)
  113. } else {
  114. this.selectValue.splice(a, 1, obj)
  115. }
  116. } else {
  117. this.selectValue.push(obj)
  118. }
  119. },
  120. // 开关,是否打开请求自定义字段以及架构的值
  121. change(val) {
  122. if (val.enabled) {
  123. if (val.isCategory == 1) {
  124. this.queryProductCategory(val)
  125. } else {
  126. this.queryCustomOption(val)
  127. }
  128. }
  129. },
  130. // 获取自定义字段
  131. async getList() {
  132. var params = {
  133. current: 1,
  134. size: 999,
  135. searchQuery: `projectId=${this.projectId}`,
  136. orderDTOList: [
  137. {
  138. "orderBy": "createTime",
  139. "orderType": 1
  140. }
  141. ],
  142. }
  143. await this.$api.queryCustomField(params).then(response => {
  144. this.field = response.data.data
  145. }).catch(error => {
  146. })
  147. },
  148. // 查询自定义栏位选项数据
  149. async queryCustomOption(row) {
  150. let params = {
  151. customFieldId: row.id,
  152. }
  153. await this.$api.queryCustomOption(params).then(response => {
  154. if (response.code == 200) {
  155. this.$set(row, 'option', response.data.data)
  156. this.$set(row, 'selected', [])
  157. }
  158. }).catch(error => {
  159. this.$set(row, 'option', [])
  160. this.$set(row, 'selected', [])
  161. })
  162. },
  163. //获取产品或产品类别架构以及技术分类
  164. queryProductCategory(item) {
  165. let params = {
  166. projectId: this.projectId,
  167. taskId: this.taskId || null,
  168. type: item.treeType,//类型:1产品类别,2产品,3技术分类,4自定义树
  169. typeId: item.fieldId,//产品或类别id
  170. }
  171. this.$api.queryTreeNodeTree(params).then(res => {
  172. if (res.code == 200) {
  173. this.$set(item, 'option', response.data.data)
  174. this.$set(item, 'selected', [])
  175. }
  176. }).catch(err => {
  177. this.$set(row, 'option', [])
  178. this.$set(row, 'selected', [])
  179. })
  180. },
  181. //获取专利信息,拿到产品或产品类别
  182. getPatent() {
  183. let params = {
  184. current: 1,//分页信息及区分同族类型
  185. size: 10,//分页信息及区分同族类型
  186. projectId: this.projectId,
  187. searchQuery: this.searchStr || '',//检索条件
  188. customFields: this.customFields || [],
  189. orderDTOList: [],//排序信息
  190. }
  191. this.$api.QueryPatent(params).then(res => {
  192. if (res.code == 200) {
  193. // treeType 3产品类别 2产品???
  194. if (res.data.data[0].trees.length > 0) {
  195. res.data.data[0].trees.forEach(item => {
  196. item.isCategory = 1
  197. this.field.push(item)
  198. })
  199. }
  200. }
  201. }).catch(error => {
  202. })
  203. },
  204. // 打开弹窗
  205. async open({ selectQuery, searchQuery, customFields }) {
  206. // console.log(selectQuery, searchQuery, customFields);
  207. this.selectQuery = selectQuery
  208. this.searchQuery = searchQuery
  209. this.customFields = customFields
  210. await this.getList()
  211. this.getPatent()
  212. this.visible = true
  213. },
  214. // 弹窗确定
  215. submit() {
  216. let params = {
  217. projectId: this.projectId,
  218. ...this.selectQuery,//选择的信息
  219. searchQuery: this.searchQuery,//检索的信息
  220. customFields: this.customFields,//自定义字段的信息
  221. esCustomFieldDTOS: this.selectValue,
  222. }
  223. this.$api.batchAddCustomField(params).then(res => {
  224. if (res.code == 200) {
  225. this.$message.success('标引成功')
  226. this.close()
  227. }
  228. })
  229. },
  230. // 弹窗关闭
  231. close() {
  232. this.visible = false
  233. },
  234. },
  235. }
  236. </script>
  237. <style lang="scss" scoped></style>