Browse Source

用户修改

flower_bs 1 month ago
parent
commit
5a4d1b52f3
2 changed files with 17 additions and 19 deletions
  1. 3 1
      staff/views.py
  2. 14 18
      templates/src/pages/staff/stafflist.vue

+ 3 - 1
staff/views.py

@@ -100,7 +100,9 @@ class APIViewSet(viewsets.ModelViewSet):
 
     def get_serializer_class(self):
 
-        staff_type = ListModel.objects.filter(appid=self.request.auth.appid, is_delete=False).first().staff_type
+        staff_name = self.request.auth.name
+        staff_type = ListModel.objects.filter(staff_name=staff_name, is_delete=False).first().staff_type
+
         if staff_type not in ['admin', '主管', '管理员','经理']:
             if self.action in ['list', 'retrieve', 'destroy']:
                 return serializers.userStaffGetSerializer

+ 14 - 18
templates/src/pages/staff/stafflist.vue

@@ -433,8 +433,8 @@ export default {
       current: 1,
       max: 0,
       total: 0,
-      paginationIpt: 1
-      , changeCodeDialog: false,
+      paginationIpt: 1,
+      changeCodeDialog: false,
       newCheckCode: null,
       selectedRow: null
     }
@@ -617,7 +617,12 @@ export default {
         _this.newFormData.staff_type
       ) {
         _this.RandomCheckCode()
-        postauth(_this.pathname, _this.newFormData)
+        // 后端存储的就是中文,直接提交
+        const submitData = {
+          ..._this.newFormData,
+          role: _this.newFormData.staff_type // 保存角色名称用于关联Role
+        }
+        postauth(_this.pathname, submitData)
           .then((res) => {
             _this.getList()
             _this.newDataCancel()
@@ -666,6 +671,7 @@ export default {
       var _this = this
       _this.editMode = true
       _this.editid = e.id
+      // 后端返回的就是中文,直接使用
       _this.editFormData = {
         staff_name: e.staff_name,
         staff_type: e.staff_type
@@ -673,22 +679,12 @@ export default {
     },
     editDataSubmit () {
       var _this = this
-      if (_this.editFormData.staff_type === '经理') {
-        _this.editFormData.staff_type = 'Manager'
-      } else if (_this.editFormData.staff_type === '主管') {
-        _this.editFormData.staff_type = 'Supervisor'
-      } else if (_this.editFormData.staff_type === '收货组') {
-        _this.editFormData.staff_type = 'Inbound'
-      } else if (_this.editFormData.staff_type === '发货组') {
-        _this.editFormData.staff_type = 'Outbound'
-      } else if (_this.editFormData.staff_type === '库存控制') {
-        _this.editFormData.staff_type = 'StockControl'
-      } else if (_this.editFormData.staff_type === '客户') {
-        _this.editFormData.staff_type = 'Customer'
-      } else if (_this.editFormData.staff_type === '供应商') {
-        _this.editFormData.staff_type = 'Supplier'
+      // 后端存储的就是中文,直接提交
+      const submitData = {
+        ..._this.editFormData,
+        role: _this.editFormData.staff_type // 保存角色名称用于关联Role
       }
-      putauth(_this.pathname + _this.editid + '/', _this.editFormData)
+      putauth(_this.pathname + _this.editid + '/', submitData)
         .then((res) => {
           _this.editDataCancel()
           _this.getList()