zhangxin 1 месяц назад
Родитель
Сommit
1636acdaec
2 измененных файлов с 284 добавлено и 154 удалено
  1. 142 133
      pages/wareHouse/components/fakeRegistration.vue
  2. 142 21
      pages/wareHouse/styles/fakeRegistration.scss

+ 142 - 133
pages/wareHouse/components/fakeRegistration.vue

@@ -1,75 +1,117 @@
1
 <template>
1
 <template>
2
   <div class="fake_registration">
2
   <div class="fake_registration">
3
-    <u-navbar class="nav-bar" title="假货登记" :autoBack="true" :placeholder="true" v-hideNav></u-navbar>
4
-    <view class="fake_table_wrap">
5
-      <view class="btn_wrap">
6
-        <u-button :type="(!isAdd && !isEdit) ? 'primary' : 'error'" :icon="(!isAdd && !isEdit) ? 'plus' : 'close'"
7
-          size="mini" :text="(!isAdd && !isEdit) ? '新增' : '取消'"
8
-          @click="(!isAdd && !isEdit) ? handleAdd() : handleCancle()"></u-button>
9
-        <u-button v-if="isAdd || isEdit" type="primary" size="mini" icon="checkmark" text="确定"
10
-          @click="handleSubmit"></u-button>
11
-      </view>
12
-      <view class="custom-table__body">
13
-        <Table ref="customTable" :tableData="tableData" :columns="columns" stripe @loadMore="handleLoadMore">
14
-          <template #cell-name="{ row, rowIndex }">
15
-            <view v-double-tap="() => editCell(row, rowIndex)">
16
-              <u--input v-if="row.edit" border="surround" v-model="row.name"></u--input>
17
-              <view v-else>{{ row.name }}</view>
18
-            </view>
19
-          </template>
20
-          <template #cell-idCard="{ row, rowIndex }">
21
-            <view v-double-tap="() => editCell(row, rowIndex)">
22
-              <u--input v-if="row.edit" border="surround" v-model="row.idCard"></u--input>
23
-              <view v-else>{{ row.idCard }}</view>
24
-            </view>
25
-          </template>
26
-          <template #cell-phone="{ row, rowIndex }">
27
-            <view v-double-tap="() => editCell(row, rowIndex)"">
28
-            <u--input v-if="row.edit" border="surround" v-model="row.phone" type="number"></u--input>
29
-              <view v-else>{{ row.phone }}</view>
30
-            </view>
31
-          </template>
32
-          <template #cell-itemName="{ row, rowIndex }">
33
-            <view v-double-tap="() => editCell(row, rowIndex)"">
34
-            <u--input v-if="row.edit" border="surround" v-model="row.itemName"></u--input>
35
-              <view v-else>{{ row.itemName }}</view>
36
-            </view>
37
-          </template>
38
-          <template #cell-remark="{ row, rowIndex }">
39
-            <view v-double-tap="() => editCell(row, rowIndex)"">
40
-            <u--input v-if="row.edit" border="surround" v-model="row.remark"></u--input>
41
-              <view v-else>{{ row.remark }}</view>
42
-            </view>
43
-          </template>
44
-        </Table>
3
+    <u-navbar class="nav-bar" title="假货登记" :autoBack="true" :placeholder="true" v-hideNav>
4
+      <template #right>
5
+        <u-button type="primary" size="mini" icon="plus" text="新增" @click="handleAdd"></u-button>
6
+      </template>
7
+    </u-navbar>
8
+    <view class="fake_list_wrap">
9
+      <view class="list_content" v-if="tableData.length > 0">
10
+          <view 
11
+            class="fake_item" 
12
+            v-for="(item, index) in tableData" 
13
+            :key="item.id || index"
14
+            :class="{ 'selected': selectedIndex === index }"
15
+            >
16
+            <!-- @click="handleItemClick(index, item)" -->
17
+            <u-swipe-action>
18
+              <u-swipe-action-item :options="swipeOptions" @click="(e) => handleSwipeClick(item, e, index)">
19
+                <view class="item_header">
20
+                  <view class="name">{{ item.name }}</view>
21
+                  <view class="phone">{{ item.phone }}</view>
22
+                </view>
23
+                <view class="item_body">
24
+                  <view class="info_item">
25
+                    <view class="label">身份证号:</view>
26
+                    <view class="value">{{ item.idCard }}</view>
27
+                  </view>
28
+                  <view class="info_item">
29
+                    <view class="label">物品:</view>
30
+                    <view class="value">{{ item.itemName }}</view>
31
+                  </view>
32
+                  <view class="info_item" v-if="item.remark">
33
+                    <view class="label">备注:</view>
34
+                    <view class="value">{{ item.remark }}</view>
35
+                  </view>
36
+                </view>
37
+              </u-swipe-action-item>
38
+            </u-swipe-action>
39
+          </view>
40
+        <u-loadmore :status="loadStatus" :loading-text="'加载中...'" :finished-text="'没有更多了'" @loadmore="handleLoadMore"></u-loadmore>
45
       </view>
41
       </view>
42
+      <u-empty v-else text="暂无假货登记信息" mode="list"></u-empty>
46
     </view>
43
     </view>
44
+    
45
+    <!-- 编辑弹窗 -->
46
+    <u-modal :show="showEditDialog" border-radius="40rpx" :title="isAdd ? '新增' : '编辑'" @confirm="handleSubmit" showCancelButton @cancel="showEditDialog = false" @close="showEditDialog = false">
47
+      <view class="edit_dialog">
48
+        <view class="dialog_content">
49
+          <u-form :model="formData" ref="formRef" :rules="rules" label-position="left">
50
+            <u-form-item label="姓名" required prop="name" label-width="70rpx">
51
+              <u--input v-model="formData.name" placeholder="请输入姓名"></u--input>
52
+            </u-form-item>
53
+            <u-form-item label="身份证号" required prop="idCard" label-width="130rpx">
54
+              <u--input v-model="formData.idCard" placeholder="请输入身份证号"></u--input>
55
+            </u-form-item>
56
+            <u-form-item label="电话" required prop="phone" label-width="70rpx">
57
+              <u--input v-model="formData.phone" type="number" placeholder="请输入电话"></u--input>
58
+            </u-form-item>
59
+            <u-form-item label="物品" required prop="itemName" label-width="70rpx">
60
+              <u--input v-model="formData.itemName" placeholder="请输入物品"></u--input>
61
+            </u-form-item>
62
+            <u-form-item label="备注" prop="remark" label-width="70rpx">
63
+              <u--input v-model="formData.remark" placeholder="请输入备注" type="textarea" :rows="3"></u--input>
64
+            </u-form-item>
65
+          </u-form>
66
+        </view>
67
+      </view>
68
+    </u-modal>
47
   </div>
69
   </div>
48
 </template>
70
 </template>
49
 
71
 
50
 <script>
72
 <script>
51
-import Table from '@/components/custom-table/index.vue'
52
 export default {
73
 export default {
53
   name: 'FakeRegistration',
74
   name: 'FakeRegistration',
54
-  components: {
55
-    Table
56
-  },
57
   data() {
75
   data() {
58
     return {
76
     return {
59
       tableData: [],
77
       tableData: [],
60
-      columns: [
61
-        { label: '姓名', prop: 'name',  isRequire: true },
62
-        { label: '身份证号', prop: 'idCard', isRequire: true},
63
-        { label: '电话', prop: 'phone', isRequire: true },
64
-        { label: '物品', prop: 'itemName', isRequire: true },
65
-        { label: '备注', prop: 'remark' },
66
-      ],
67
-      isAdd: false,
68
-      isEdit: false,
69
-      editIndex: null,
70
       pageNum: 1,
78
       pageNum: 1,
71
       pageSize: 10,
79
       pageSize: 10,
72
-      total:0
80
+      total: 0,
81
+      loadStatus: 'more',
82
+      showEditDialog: false,
83
+      isAdd: false,
84
+      currentEditItem: null,
85
+      selectedIndex: -1,
86
+      formData: {
87
+        id: '',
88
+        name: '',
89
+        idCard: '',
90
+        phone: '',
91
+        itemName: '',
92
+        remark: ''
93
+      },
94
+      swipeOptions: [
95
+        {
96
+          text: '编辑',
97
+          style: {
98
+            backgroundColor: '#343a40',
99
+            color: '#fff'
100
+          }
101
+        }
102
+      ],
103
+      rules: {
104
+        name: [{ required: true, message: '请输入姓名', trigger: 'change' }],
105
+        idCard: [
106
+          { required: true, message: '请输入身份证号', trigger: 'change' },
107
+          { pattern: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/, message: '请输入正确的身份证号', trigger: 'change' }
108
+        ],
109
+        phone: [
110
+          { required: true, message: '请输入电话', trigger: 'change'},
111
+          { pattern: /^1[3-9]\d{9}$/, message: '请输入正确的电话号', trigger: 'change' }
112
+        ],
113
+        itemName: [{ required: true, message: '请输入物品', trigger: 'change' }],
114
+      }
73
     }
115
     }
74
   },
116
   },
75
   mounted() {
117
   mounted() {
@@ -78,7 +120,7 @@ export default {
78
   methods: {
120
   methods: {
79
     handleLoadMore() {
121
     handleLoadMore() {
80
       if (this.pageNum * this.pageSize >= this.total) {
122
       if (this.pageNum * this.pageSize >= this.total) {
81
-        uni.$u.toast('没有更多数据了')
123
+        this.loadStatus = 'noMore'
82
         return
124
         return
83
       }
125
       }
84
       this.pageNum++
126
       this.pageNum++
@@ -95,98 +137,65 @@ export default {
95
           this.tableData = this.tableData.concat(res.rows)
137
           this.tableData = this.tableData.concat(res.rows)
96
         }
138
         }
97
         this.total = res.total
139
         this.total = res.total
140
+        this.loadStatus = 'more'
98
       })
141
       })
99
     },
142
     },
100
-    editCell(row, rowIndex) {
101
-      this.editIndex = rowIndex
102
-      this.$set(this.tableData[rowIndex], 'edit', true);
103
-      this.isEdit = true
143
+    handleAdd() {
144
+      this.isAdd = true
145
+      this.currentEditItem = null
146
+      this.formData = {
147
+        id: '',
148
+        name: '',
149
+        idCard: '',
150
+        phone: '',
151
+        itemName: '',
152
+        remark: ''
153
+      }
154
+      this.showEditDialog = true
155
+    },
156
+    handleItemClick(index, item) {
157
+      this.selectedIndex = index;
158
+    },
159
+    handleSwipeClick(item, e, index) {
160
+      if(e.index == 0){//编辑
161
+        this.selectedIndex = index;
162
+        setTimeout(() => {
163
+          this.isAdd = false
164
+          this.currentEditItem = item
165
+          this.formData = {
166
+            id: item.id,
167
+            name: item.name,
168
+            idCard: item.idCard,
169
+            phone: item.phone,
170
+            itemName: item.itemName,
171
+            remark: item.remark || ''
172
+          }
173
+          this.showEditDialog = true
174
+        }, 300);
175
+      }
104
     },
176
     },
105
     handleSubmit() {
177
     handleSubmit() {
106
-      if (this.isAdd) {
107
-        if (this.checkEmpty(this.tableData[0])) {
108
-          uni.$u.api.wareHouseFakeAdd(this.tableData[0]).then(res => {
178
+      this.$refs.formRef.validate().then(() => {
179
+        if (this.isAdd) {
180
+          uni.$u.api.wareHouseFakeAdd(this.formData).then(res => {
109
             if (res.code == 200) {
181
             if (res.code == 200) {
110
-              this.$set(this.tableData[0], 'edit', false)
111
-              this.isAdd = false
112
               uni.$u.toast('新增成功')
182
               uni.$u.toast('新增成功')
183
+              this.showEditDialog = false
113
               this.pageNum = 1
184
               this.pageNum = 1
114
               this.getWareHouseFakeList()
185
               this.getWareHouseFakeList()
115
             }
186
             }
116
           })
187
           })
117
-        }
118
-      }
119
-      if (this.isEdit) {
120
-        if (this.checkEmpty(this.tableData[this.editIndex])) {
121
-          uni.$u.api.wareHouseFakeEdit(this.tableData[this.editIndex]).then(res => {
188
+        } else {
189
+          uni.$u.api.wareHouseFakeEdit(this.formData).then(res => {
122
             if (res.code == 200) {
190
             if (res.code == 200) {
123
-              this.$set(this.tableData[this.editIndex], 'edit', false)
124
-              this.isEdit = false
125
               uni.$u.toast('编辑成功')
191
               uni.$u.toast('编辑成功')
192
+              this.showEditDialog = false
126
               this.getWareHouseFakeList()
193
               this.getWareHouseFakeList()
127
             }
194
             }
128
           })
195
           })
129
         }
196
         }
130
-      }
131
-    },
132
-    checkEmpty(row) {
133
-      if (row.name == '') {
134
-        uni.$u.toast('请输入姓名')
135
-        return false
136
-      }
137
-      if (row.idCard == '') {
138
-        uni.$u.toast('请输入身份证号')
139
-        return false
140
-      }
141
-      // 身份证号正则校验
142
-      const idCardRegex = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
143
-      if (!idCardRegex.test(row.idCard)) {
144
-        uni.$u.toast('请输入有效的身份证号')
145
-        return false
146
-      }
147
-      if (row.phone == '') {
148
-        uni.$u.toast('请输入电话')
149
-        return false
150
-      }
151
-      // 电话号码正则校验
152
-      const phoneRegex = /^1[3-9]\d{9}$/
153
-      if (!phoneRegex.test(row.phone)) {
154
-        uni.$u.toast('请输入有效的电话号码')
155
-        return false
156
-      }
157
-      if (row.itemName == '') {
158
-        uni.$u.toast('请输入物品')
159
-        return false
160
-      }
161
-      return true
162
-    },
163
-    addNewRow() {
164
-      this.$refs.customTable.addNewRow();
165
-    },
166
-    handleUpdate(data) {
167
-      console.log('数据更新:', data);
168
-    },
169
-    handleAdd() {
170
-      this.tableData.unshift({
171
-        edit: true,
172
-        name: '',
173
-        idCard: '',
174
-        phone: '',
175
-        itemName: '',
176
-        remark: ''
177
       })
197
       })
178
-      this.isAdd = true
179
-    },
180
-    handleCancle() {
181
-      if (this.isAdd) {
182
-        this.tableData.shift(1)
183
-        this.isAdd = false
184
-      }
185
-      if (this.isEdit) {
186
-        this.$set(this.tableData[this.editIndex], 'edit', false)
187
-        this.isEdit = false
188
-      }
189
-    },
198
+    }
190
   }
199
   }
191
 }
200
 }
192
 </script>
201
 </script>

+ 142 - 21
pages/wareHouse/styles/fakeRegistration.scss

@@ -1,27 +1,148 @@
1
 .fake_registration{
1
 .fake_registration{
2
-    padding: 20rpx;
3
-    .fake_table_wrap{
4
-        display: flex;
5
-        flex-direction: column;
6
-        justify-content: flex-start;
7
-        align-items: flex-start;
8
-        gap: 20rpx;
9
-        ::v-deep .u-button{
10
-            width:auto;
2
+    padding: 0 20rpx;
3
+    min-height: 100vh;
4
+    background-color: #f8f9fa;
5
+    font-family: 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
6
+    
7
+    .fake_list_wrap{
8
+        margin-top: 20rpx;
9
+        min-height: calc(100vh - 120rpx);
10
+        
11
+        .list_content{
12
+            .fake_item{
13
+                background-color: #ffffff;
14
+                border-radius: 16rpx;
15
+                padding: 32rpx;
16
+                margin-bottom: 16rpx;
17
+                box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
18
+                transition: all 0.3s ease;
19
+                border: 1rpx solid #e9ecef;
20
+                
21
+                &.selected{
22
+                    box-shadow: 0 12rpx 32rpx rgba(71, 130, 241, 0.2);
23
+                    transform: translateY(-5rpx) scale(1.02);
24
+                    border-color: #4782f1;
25
+                    border-width: 2rpx;
26
+                    z-index: 10;
27
+                }
28
+                
29
+                .item_header{
30
+                    display: flex;
31
+                    justify-content: space-between;
32
+                    align-items: center;
33
+                    margin-bottom: 24rpx;
34
+                    padding-bottom: 20rpx;
35
+                    border-bottom: 1rpx dashed #e9ecef;
36
+                    
37
+                    .name{
38
+                        font-size: 32rpx;
39
+                        font-weight: 700;
40
+                        color: #212529;
41
+                        position: relative;
42
+                        padding-left: 20rpx;
43
+                        
44
+                        &::before{
45
+                            content: '';
46
+                            position: absolute;
47
+                            left: 0;
48
+                            top: 50%;
49
+                            transform: translateY(-50%);
50
+                            width: 8rpx;
51
+                            height: 8rpx;
52
+                            border-radius: 50%;
53
+                            background-color: #4782f1;
54
+                        }
55
+                    }
56
+                    
57
+                    .phone{
58
+                        font-size: 26rpx;
59
+                        color: #6c757d;
60
+                        padding: 6rpx 16rpx;
61
+                        border-radius: 16rpx;
62
+                    }
63
+                }
64
+                
65
+                .item_body{
66
+                    .info_item{
67
+                        display: flex;
68
+                        align-items: center;
69
+                        margin-bottom: 16rpx;
70
+                        font-size: 26rpx;
71
+                        line-height: 44rpx;
72
+                        
73
+                        &:last-child{
74
+                            margin-bottom: 0;
75
+                        }
76
+                        
77
+                        .label{
78
+                            color: #868e96;
79
+                            min-width: 120rpx;
80
+                            font-weight: 500;
81
+                        }
82
+                        
83
+                        .value{
84
+                            color: #495057;
85
+                            flex: 1;
86
+                            word-break: break-word;
87
+                            padding: 4rpx 12rpx;
88
+                            border-radius: 8rpx;
89
+                            font-size: 24rpx;
90
+                        }
91
+                    }
92
+                }
93
+            }
94
+            
95
+            .u-loadmore{
96
+                margin-top: 30rpx;
97
+                margin-bottom: 40rpx;
98
+            }
11
         }
99
         }
12
-        .btn_wrap{
13
-            display: flex;
14
-            gap: 20rpx;
100
+        
101
+        .u-empty{
102
+            margin-top: 120rpx;
103
+        }
104
+    }
105
+    
106
+    // 编辑弹窗样式
107
+    .edit_dialog{
108
+        width: 85%;
109
+        max-width: 520rpx;
110
+        border-radius: 16rpx;
111
+        overflow: hidden;
112
+        
113
+        .dialog_title{
114
+            font-size: 34rpx;
115
+            font-weight: 700;
116
+            color: #212529;
117
+            text-align: center;
118
+            padding: 36rpx 24rpx;
119
+            border-bottom: 1rpx solid #e9ecef;
15
         }
120
         }
16
-        .custom-table__body{
17
-            height: calc(100vh - 240rpx);
18
-            width: -webkit-fill-available;
19
-            border-radius: 20rpx;
20
-            background-color: #fff;
21
-            overflow-y: auto;
22
-            ::v-deep .custom-table{
23
-                margin:20rpx;
24
-                // width: 100%;
121
+        
122
+        .dialog_content{
123
+            padding: 36rpx 28rpx;
124
+            
125
+            .u-form-item{
126
+                
127
+                .u-form-item__label{
128
+                    font-size: 28rpx;
129
+                    font-weight: 600;
130
+                    color: #495057;
131
+                    margin-bottom: 12rpx;
132
+                    display: block;
133
+                }
134
+                
135
+                .u-input{
136
+                    border-radius: 8rpx;
137
+                    border: 1rpx solid #ced4da;
138
+                    transition: all 0.3s ease;
139
+                    
140
+                    &:focus{
141
+                        border-color: #4782f1;
142
+                        box-shadow: 0 0 0 4rpx rgba(71, 130, 241, 0.1);
143
+                        background-color: #ffffff;
144
+                    }
145
+                }
25
             }
146
             }
26
         }
147
         }
27
     }
148
     }