br-dionysus 0.9.8 → 0.9.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -282,6 +282,8 @@ const test = ref<number>(0)
282
282
  scrollbarAlwaysOn
283
283
  allowCreate
284
284
  filterable
285
+ remote
286
+ :remoteMethod="remoteMethod"
285
287
  ></m-new-select-table>
286
288
  </template>
287
289
  <!--
@@ -296,42 +298,7 @@ isAffirmBtn
296
298
  <script setup lang="ts">
297
299
  import { ref, onMounted } from 'vue'
298
300
  import { Page } from 'packages/typings/class'
299
-
300
- const urlPath = 'http://192.168.3.160:8098'
301
-
302
- const api = (url: string | URL, method: string, data: any, callback: (arg0: Error | null, arg1: string | undefined) => void) => {
303
- var xhr = new XMLHttpRequest()
304
- xhr.timeout = 1000 * 60 * 60
305
-
306
- if (method === 'GET' && data) {
307
- // 构建查询字符串
308
- var params = new URLSearchParams()
309
- for (var key in data) {
310
- params.append(key, data[key])
311
- }
312
-
313
- // 将查询字符串附加到URL上
314
- url += '?' + params.toString()
315
- }
316
- xhr.open(method, url, true)
317
- // 设置请求头
318
- // for (var key in headers) {
319
- xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8')
320
- // }
321
-
322
- xhr.onreadystatechange = function () {
323
- if (xhr.readyState === XMLHttpRequest.DONE) {
324
- if (xhr.status === 200) {
325
- // 请求成功
326
- callback(null, xhr.responseText)
327
- } else {
328
- // 请求失败
329
- callback(new Error('请求失败'), '')
330
- }
331
- }
332
- }
333
- xhr.send(JSON.stringify(data))
334
- }
301
+ import createHash from '../../../tool/createHash'
335
302
 
336
303
  const commodityOptionsTitle: TableTitle[] = [{
337
304
  prop: 'PRDocType',
@@ -357,25 +324,21 @@ const code = ref<string | number | Array<string | number>>('')
357
324
 
358
325
  const total = ref(0)
359
326
  const options = ref<any[]>([])
360
- const getDataList = (page: Page = new Page(), str: any = '') => {
361
- const params = {
362
- KeyWord: str,
363
- Group: '1',
364
- Process: 100,
365
- Status: 100,
366
- Page: page?.currentPage || 1,
367
- Limit: page?.pageSize || 5,
368
- userCode: 'demo',
369
- orgId: '1002210140000050',
370
- entId: '002'
371
- }
372
- api(urlPath + '/queryPLMPRList', 'POST', params, (err, response: any) => {
373
- const res = JSON.parse(response)
374
- options.value = res.data
375
- total.value = res.count
327
+ let mockData: any[] = []
328
+ for (let i = 0; i < 1000; i++) {
329
+ mockData.push({
330
+ PRDocType: '测试数据' + (i + 1),
331
+ DocNo: createHash(),
332
+ ApprovedQtyPU: 'ApprovedQtyPU',
333
+ ACCode: 'ACCode'
334
+ })
335
+ }
336
+ const getDataList = (page: Page = new Page(), str: string = '') => {
337
+ setTimeout(() => {
338
+ options.value = mockData.filter(item => item.DocNo.includes(str)).slice(0, page.pageSize)
339
+ total.value = mockData.length
376
340
  })
377
341
  }
378
-
379
342
 
380
343
  const selected = (value: string | number | Array<number | string>, row: any) => {
381
344
  console.log(value)
@@ -392,29 +355,18 @@ const selectMultiple = (value: string | number | Array<number | string>, row: an
392
355
  code.value = value
393
356
  }
394
357
 
395
- const remoteMethod = (query: string, page: any) => {
358
+ const remoteMethod = async (query: string, page: any) => {
396
359
  console.log(query)
397
- getData(query, page)
398
- }
399
- const getData = (query: string, page: any) => {
400
- // if(query){
401
- const params = {
402
- KeyWord: query,
403
- Group: '1',
404
- Process: 100,
405
- Status: 100,
406
- Page: page?.currentPage || 1,
407
- Limit: page?.pageSize || 5,
408
- userCode: 'demo',
409
- orgId: '1002210140000050',
410
- entId: '002'
411
- }
412
- api(urlPath + '/queryPLMPRList', 'POST', params, (err, response: any) => {
413
- const res = JSON.parse(response)
414
- options.value = res.data
415
- total.value = res.count
360
+ await getData(query, page)
361
+ }
362
+ const getData = async (query: string, page: any) => {
363
+ return new Promise<void>((resolve) => {
364
+ setTimeout(() => {
365
+ options.value = mockData.filter(item => item.DocNo.includes(query)).slice(0, page.pageSize)
366
+ total.value = mockData.length
367
+ resolve()
368
+ }, 500)
416
369
  })
417
- // }
418
370
  }
419
371
 
420
372
  onMounted(() => {
@@ -425,9 +377,6 @@ const filterMethod = (searchValue: string, page: Page) => {
425
377
  const arr = JSON.parse(JSON.stringify(options.value))
426
378
  options.value = arr.filter((item: any) => item.ApprovedQtyPU.toString().includes(searchValue))
427
379
  }
428
- // setTimeout(()=>{
429
- // selectRef.value.focus()
430
- // })
431
380
  </script>
432
381
 
433
382
  <style>