z8018
8 天以前 d5317aef1dbb595923af02ede8bfa33ba37d6eb6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import {
    insert,
    query
} from "../common/sqlite"
 
export default {
    async getScanRecord(orderNo, materialName) {
        try {
            return query('select count(*) AS quantity from scan_records where orderNo = ? and materialName = ?', [
                orderNo,
                materialName
            ])
        } catch (e) {
            console.error('getScanRecord', e)
        }
    },
 
    async getScanRecords(orderNo, materialName) {
        try {
            return query('select * from scan_records where orderNo = ? and materialName = ? order by scan_time desc', [orderNo,
                materialName
            ])
        } catch (e) {
            console.error('getScanRecord', e)
        }
    },
 
    async saveScanRecord(orderNo, materialName, scanContent, contents) {
        try {
            let referenceContent = '';
            const createTime = new Date().toISOString()
 
            if (typeof contents[0] == 'object') {
                for (var index = 0; index < contents.length; index++) {
                    var element = contents[index];
                    if (index > 0) {
                        referenceContent += '@#@'
                    }
                    referenceContent += element.text;
                }
            } else {
                referenceContent = contents.join("@#@")
            }
 
            return await insert('scan_records', {
                orderNo: orderNo,
                materialName: materialName,
                scan_content: scanContent,
                reference_content: referenceContent,
                is_matched: true,
                scan_time: createTime
            })
        } catch (e) {
            console.error('saveScanRecord', e)
        }
    }
}