fastSelectPatent.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. // 选择专利js
  2. export const fastSelectPatent = {
  3. data() {
  4. return {
  5. // 数据
  6. tableData: [],
  7. //总数
  8. total: 0,
  9. //分页及选择专利的信息
  10. queryParams: {
  11. current: 1,
  12. size: 10,
  13. groupField: '0',
  14. selected: [],
  15. isAdd: [],
  16. isDelete: [],
  17. },
  18. //是否编辑//编辑按钮暂时隐藏,改为默认为true
  19. refresh: true,
  20. //选择的专利集合
  21. patentNoList: [],
  22. //选择总数
  23. selectedTotal: 0,
  24. //选择专利加载
  25. selectNumberLoading: false,
  26. // 起始位置
  27. startNumber: 1,
  28. // 结束位置
  29. endNumber: 0,
  30. // 判断是否是全部选择或范围选择
  31. quickSelect: false,
  32. quickSelectArr: [],
  33. }
  34. },
  35. mounted() {
  36. if(!this.taskType || this.taskType == 0){
  37. this.refresh = true
  38. }else{
  39. this.refresh = false
  40. }
  41. },
  42. methods: {
  43. // 是否刷新
  44. isRefresh() {
  45. if(!this.refresh){
  46. return
  47. }
  48. this.refresh = false
  49. this.$nextTick(() => {
  50. this.refresh = true
  51. })
  52. },
  53. //快速选择
  54. handleSelectNumber(type) {
  55. switch (type) {
  56. case 0: //本页选择
  57. var patentNos = this.$store.state.patent.records.map((item) => item.patentNo)
  58. if(this.quickSelect){
  59. var arr = patentNos.filter(item=>{
  60. return this.patentNoList.indexOf(item) == -1
  61. })
  62. if(arr.length>0){
  63. arr.forEach(item => {
  64. this.getChoosePatentNo(item)
  65. });
  66. }
  67. }else{
  68. this.queryParams.isAdd = [...new Set(this.queryParams.isAdd.concat(patentNos)),];
  69. }
  70. this.patentNoList = [...new Set(this.patentNoList.concat(patentNos)),];
  71. break;
  72. case 1: //全部选择
  73. this.startNumber = 1;
  74. this.endNumber = this.total;
  75. this.$set(this.queryParams, 'startNumber', 1)
  76. this.$set(this.queryParams, 'endNumber', this.total)
  77. case 2: //范围选择
  78. this.queryParams.isDelete = [];
  79. this.queryParams.isAdd = [];
  80. this.patentNoList = [];
  81. this.quickSelect = true;
  82. if (type == 2) {
  83. if (!Number(this.queryParams.startNumber) || !Number(this.queryParams.endNumber)) {
  84. this.$set(this.queryParams, 'startNumber', this.startNumber > 0 ? this.startNumber : 1)
  85. this.$set(this.queryParams, 'endNumber', this.endNumber > 0 ? this.endNumber : this.total)
  86. break;
  87. }
  88. this.startNumber = this.queryParams.startNumber;
  89. this.endNumber = this.queryParams.endNumber;
  90. }
  91. this.commonSwitch();
  92. break;
  93. }
  94. this.getSelectedTotal()
  95. this.isRefresh()
  96. },
  97. //每页全部选择或范围选择的专利
  98. commonSwitch() {
  99. var arr = []
  100. if (this.queryParams.size * this.queryParams.current >= this.startNumber) {
  101. if (this.queryParams.size * this.queryParams.current >= this.endNumber) {
  102. if (this.queryParams.size * (this.queryParams.current - 1) + 1 <= this.startNumber) {
  103. var a = this.startNumber - (this.queryParams.size * (this.queryParams.current - 1) + 1);
  104. var b = this.endNumber - (this.queryParams.size * (this.queryParams.current - 1) + 1);
  105. for (var y = a; y <= b; y++) {
  106. arr.push(this.tableData[y].patentNo)
  107. }
  108. } else {
  109. var a = this.queryParams.size * (this.queryParams.current - 1) + 1 - (this.queryParams.size * (this.queryParams.current - 1) + 1);
  110. var b = this.endNumber - (this.queryParams.size * (this.queryParams.current - 1) + 1);
  111. for (var y = a; y <= b; y++) {
  112. arr.push(this.tableData[y].patentNo)
  113. }
  114. }
  115. } else {
  116. if (this.queryParams.size * (this.queryParams.current - 1) + 1 <= this.startNumber) {
  117. var a = this.startNumber - (this.queryParams.size * (this.queryParams.current - 1) + 1);
  118. var b = this.queryParams.size * this.queryParams.current - (this.queryParams.size * (this.queryParams.current - 1) + 1);
  119. for (var y = a; y <= b; y++) {
  120. arr.push(this.tableData[y].patentNo)
  121. }
  122. } else {
  123. var a = this.queryParams.size * (this.queryParams.current - 1) + 1 - (this.queryParams.size * (this.queryParams.current - 1) + 1);
  124. var b = this.queryParams.size * this.queryParams.current - (this.queryParams.size * (this.queryParams.current - 1) + 1);
  125. for (var y = a; y <= b; y++) {
  126. arr.push(this.tableData[y].patentNo)
  127. }
  128. }
  129. }
  130. }
  131. // this.patentNoList = JSON.parse(JSON.stringify(arr))
  132. this.quickSelectArr = JSON.parse(JSON.stringify(arr))
  133. this.getHaveChoose(arr)
  134. },
  135. //获取已选择的专利
  136. getHaveChoose(arr) {
  137. var arr1 = [...new Set(arr.concat(this.queryParams.isAdd))]
  138. this.patentNoList = arr1.filter((x) => this.queryParams.isDelete.indexOf(x) == -1)
  139. },
  140. //获取已选择的总条数
  141. getSelectedTotal() {
  142. this.selectedTotal = Number(this.endNumber) - Number(this.startNumber) + 1 + Number(this.queryParams.isAdd.length) - Number(this.queryParams.isDelete.length)
  143. },
  144. //获取手动选择的专利
  145. getChoosePatentNo(patentNo) {
  146. if (this.quickSelect) {
  147. var index = this.queryParams.isDelete.findIndex(item => {
  148. return item == patentNo
  149. })
  150. if (index == -1) {
  151. var index2 = this.quickSelectArr.findIndex(item => {
  152. return item == patentNo
  153. })
  154. if (index2 == -1) {
  155. this.setIsAdd(patentNo)
  156. } else {
  157. this.queryParams.isDelete.push(patentNo)
  158. }
  159. } else {
  160. this.queryParams.isDelete.splice(index, 1)
  161. }
  162. } else {
  163. this.setIsAdd(patentNo)
  164. }
  165. this.getSelectedTotal()
  166. },
  167. //是否加入isAdd里面
  168. setIsAdd(patentNo) {
  169. var index = this.queryParams.isAdd.findIndex(item => {
  170. return item == patentNo
  171. })
  172. if (index != -1) {
  173. this.queryParams.isAdd.splice(index, 1)
  174. } else {
  175. this.queryParams.isAdd.push(patentNo)
  176. }
  177. },
  178. //取消选择
  179. handleCancelSelectNumber() {
  180. this.patentNoList = [];
  181. this.queryParams.isAdd = []
  182. this.queryParams.isDelete = []
  183. this.startNumber = 1
  184. this.queryParams.startNumber = 1
  185. this.queryParams.endNumber = this.total
  186. this.endNumber = 0
  187. this.quickSelect = false
  188. this.selectedTotal = 0
  189. // this.getList()
  190. this.isRefresh()
  191. },
  192. // 范围选择起始数字框
  193. change1(val) {
  194. if (!isNaN(val)) {
  195. if (!val || val <= 0) {
  196. this.queryParams.startNumber = 1
  197. } else {
  198. if (this.queryParams.startNumber > this.total) {
  199. this.queryParams.startNumber = this.total
  200. }
  201. }
  202. } else {
  203. this.queryParams.startNumber = 1
  204. }
  205. },
  206. // 范围选择截止数字框
  207. change2(val) {
  208. if (!isNaN(val)) {
  209. if (!val || val <= 0) {
  210. this.queryParams.endNumber = this.total
  211. } else {
  212. if (this.queryParams.endNumber > this.total) {
  213. this.queryParams.endNumber = this.total
  214. }
  215. }
  216. } else {
  217. this.queryParams.endNumber = this.total
  218. }
  219. },
  220. // 批量标引
  221. async handleIndex() {
  222. if(!(await this.$permission.projectPermission(this.projectId))){
  223. this.$showPermissionDialog()
  224. return false
  225. }
  226. let obj = {
  227. isAdd: this.queryParams.isAdd,
  228. isDelete: this.queryParams.isDelete,
  229. startNumber: this.startNumber,
  230. endNumber: this.endNumber,
  231. searchQuery: this.searchStr,
  232. customFields: this.customFields,
  233. groupField:this.queryParams.groupField,
  234. orderDTOList:this.sort,
  235. }
  236. this.$refs.PatentBatchIndexVue.open(obj)
  237. },
  238. //批量删除专利
  239. async deletePatents(){
  240. if(!(await this.$permission.projectPermission(this.projectId))){
  241. this.$showPermissionDialog()
  242. return false
  243. }
  244. this.$confirm('确认删除选择的专利吗?', '提示', {
  245. confirmButtonText: '确定',
  246. cancelButtonText: '取消',
  247. type: 'warning'
  248. }).then(() => {
  249. var params = {
  250. isAdd:this.queryParams.isAdd,
  251. isDelete: this.queryParams.isDelete,
  252. startNumber: this.startNumber,
  253. endNumber: this.endNumber,
  254. searchQuery: this.searchStr,
  255. customFields: this.customFields,
  256. groupField:this.queryParams.groupField,
  257. orderDTOList:this.sort,
  258. projectId:this.projectId
  259. }
  260. this.loading =true
  261. this.$api.deletePatents(params).then(res=>{
  262. if(res.code == 200){
  263. this.queryParams = {
  264. current: 1,
  265. size: 10,
  266. groupField: '0',
  267. selected: [],
  268. isAdd: [],
  269. isDelete: [],
  270. }
  271. this.endNumber = 0
  272. this.startNumber = 1
  273. this.getSelectedTotal()
  274. this.loading = false
  275. this.$message.success('删除成功')
  276. this.handleCancelSelectNumber()
  277. this.getList()
  278. if(this.$refs.customFields){
  279. this.$refs.customFields.refreshOptions(1)
  280. }
  281. }
  282. }).catch(error=>{
  283. this.loading = false
  284. this.$message.error('删除失败')
  285. })
  286. })
  287. },
  288. },
  289. }