kevin_zhangl há 3 anos atrás
pai
commit
4ce2769838

+ 1 - 0
backendApi/config/menu.php

@@ -367,6 +367,7 @@ return [
             ['name'=>'Article Management', 'class'=>'', 'icon'=>'', 'controller'=>'article', 'action'=>'index', 'routePath'=>'article/index', 'show'=>1,],//文章列表
             ['name'=>'添加文章', 'class'=>'', 'icon'=>'', 'controller'=>'article', 'action'=>'add', 'routePath'=>'article/add', 'show'=>0,],
             ['name'=>'编辑文章', 'class'=>'', 'icon'=>'', 'controller'=>'article', 'action'=>'edit', 'routePath'=>'article/edit', 'show'=>0,],
+            ['name'=>'文章排序', 'class'=>'', 'icon'=>'', 'controller'=>'article', 'action'=>'edit', 'routePath'=>'article/sort', 'show'=>0,],
             ['name'=>'删除文章', 'class'=>'', 'icon'=>'', 'controller'=>'article', 'action'=>'article-delete', 'routePath'=>'article/article-delete', 'show'=>0,],
 
         ]

+ 1 - 0
backendApi/config/urlManagerRules.php

@@ -504,6 +504,7 @@ return [
             'GET,POST category-delete' => 'category-delete',
             'GET category-sort' => 'category-sort',
             'POST upload' => 'upload',
+            'GET sort' => 'sort',
         ],
     ],
     [

+ 21 - 3
backendApi/modules/v1/controllers/ArticleController.php

@@ -84,8 +84,8 @@ class ArticleController extends BaseController
      */
     public function actionIndex(){
         $data = Article::lists('', [], [
-            'select' => 'ID,TITLE,CID,STATUS,CREATED_AT',
-            'orderBy' => 'CREATED_AT',
+            'select' => 'ID,TITLE,CID,STATUS,SORT,CREATED_AT',
+            'orderBy' => 'SORT ASC,CREATED_AT DESC',
         ]);
         // 全部分类
         $data['allCategory'] = ArticleCategory::getAllCategory();
@@ -152,7 +152,7 @@ class ArticleController extends BaseController
         $id = \Yii::$app->request->get('id');
         $data = null;
         if($id){
-            $data = Article::findOneAsArray('ID=:ID AND STATUS=1', [':ID'=>$id], 'ID,TITLE,CID,CREATED_AT');
+            $data = Article::findOneAsArray('ID=:ID AND STATUS=1', [':ID'=>$id], 'ID,TITLE,CID,SORT,CREATED_AT');
         }
         if($data){
             // 暂时先从文件中取内容
@@ -191,4 +191,22 @@ class ArticleController extends BaseController
             return static::notice($token);
         }
     }
+
+    /**
+     * 排序
+     * @return mixed
+     * @throws \yii\web\HttpException
+     */
+    public function actionSort()
+    {
+        if (Yii::$app->request->get('id')) {
+            $formModel = new ArticleForm();
+            $formModel->scenario = 'sort';
+            if ($formModel->load(Yii::$app->request->get(), '') && $formModel->sortTo()) {
+                return static::notice('Success');
+            } else {
+                return static::notice('Fail', 400);
+            }
+        }
+    }
 }

+ 5 - 0
backendEle/src/views/article/edit.vue

@@ -10,6 +10,9 @@
             <el-option v-for="item in allCategory" :label="item.CATE_NAME" :value="item.ID" :key="item.ID"></el-option>
           </el-select>
         </el-form-item>
+        <el-form-item label="Order" style="width: 500px;"><!--排序值-->
+            <el-input v-model="form.sort"></el-input>
+        </el-form-item>
         <el-form-item label="Content"><!--内容-->
           <editor id="contentEditor" :cloud-channel="editorRootUrl" ref="contentEditor" v-model="form.content"
                   :init="editorOptions"></editor>
@@ -41,6 +44,7 @@ export default {
         this.form.title = response.oneData.TITLE
         this.form.cid = response.oneData.CID
         this.form.content = response.oneData.CONTENT
+        this.form.sort = response.oneData.SORT
         this.allCategory = response.allCategory
         this.loading = false
         this.isEdit = true
@@ -58,6 +62,7 @@ export default {
         title: '',
         cid: null,
         content: '',
+        sort: 1,
       },
       allCategory: null,
       loading: false,

+ 10 - 0
backendEle/src/views/article/index.vue

@@ -22,6 +22,11 @@
             {{allData.allCategory[scope.row.CID].CATE_NAME}}
           </template>
         </el-table-column>
+        <el-table-column label="Sort" width="100"> <!-- 排序 -->
+          <template slot-scope="scope">
+            <el-input v-model="scope.row.SORT" min="0" max="99" @change="handleChangeSort(scope.row, scope.row.SORT)"></el-input>
+          </template>
+        </el-table-column>
         <el-table-column label="Creation time"><!--创建时间-->
           <template slot-scope="scope">
             {{tool.formatDate(scope.row.CREATED_AT)}}
@@ -111,6 +116,11 @@ export default {
     handleMuliDel () {
       this.delData()
     },
+    handleChangeSort (row, sort) {
+      network.getData('/article/sort', {id: row.ID, sort: sort}).then(_ => {
+        this.getData(this.currentPage, this.pageSize)
+      })
+    },
     getData (page, pageSize) {
       let obj = this
       network.getPageData(this, 'article/index', page, pageSize, this.filterData, function (response) {

+ 8 - 6
common/models/Article.php

@@ -12,6 +12,7 @@ use Yii;
  * @property string $CID 分类ID
  * @property string $CONTENT 内容
  * @property int $STATUS 状态
+ * @property int $SORT 排序值
  * @property int $CREATED_AT 创建时间
  */
 class Article extends \common\components\ActiveRecord
@@ -31,7 +32,7 @@ class Article extends \common\components\ActiveRecord
     {
         return [
             [['CID', 'CREATED_AT'], 'required'],
-            [['STATUS', 'CREATED_AT'], 'integer'],
+            [['STATUS', 'CREATED_AT', 'SORT'], 'integer'],
             [['ID', 'CID'], 'string', 'max' => 32],
             [['TITLE'], 'string', 'max' => 255],
             [['CONTENT'], 'string', 'max' => 4000],
@@ -47,11 +48,12 @@ class Article extends \common\components\ActiveRecord
     {
         return [
             'ID' => 'ID',
-            'TITLE' => '标题',
-            'CID' => '分类ID',
-            'CONTENT' => '内容',
-            'STATUS' => '状态',
-            'CREATED_AT' => '创建时间',
+            'TITLE' => 'Title', // 标题
+            'CID' => 'Category Type', // 分类
+            'CONTENT' => 'Content', // 内容
+            'STATUS' => 'State', // 状态
+            'Order' => 'Sort', // 排序
+            'CREATED_AT' => 'Creation Time', // 创建时间
         ];
     }
 }

+ 28 - 5
common/models/forms/ArticleForm.php

@@ -16,6 +16,7 @@ class ArticleForm extends Model
     public $id;
     public $title;
     public $cid;
+    public $sort;
     public $content;
 
     /**
@@ -36,9 +37,10 @@ class ArticleForm extends Model
     {
         return [
             'id' => 'ID',
-            'title' => '标题',
-            'cid' => '分类',
-            'content' => '内容',
+            'title' => 'Title',//标题
+            'cid' => 'Type', // 分类
+            'content' => 'Content', // 内容
+            'sort' => 'Sort', // 排序
         ];
     }
 
@@ -50,8 +52,9 @@ class ArticleForm extends Model
     {
         $parentScenarios =  parent::scenarios();
         $customScenarios = [
-            'add' => ['title', 'cid', 'content'],
-            'edit' => ['id','title', 'cid', 'content'],
+            'add' => ['title', 'cid', 'content', 'sort'],
+            'edit' => ['id','title', 'cid', 'content', 'sort'],
+            'sort' => ['id', 'sort'],
         ];
         return array_merge($parentScenarios, $customScenarios);
     }
@@ -73,6 +76,8 @@ class ArticleForm extends Model
                 $model->CREATED_AT = Date::nowTime();
             } elseif($this->scenario == 'edit') {
                 $model = Article::findOne(['ID'=>$this->id]);
+            }  elseif($this->scenario == 'sort') {
+                $model = Article::findOne(['ID'=>$this->id]);
             } else {
                 $this->addError('edit', 'Scenario not exists');// 提交场景不存在
                 return null;
@@ -81,6 +86,7 @@ class ArticleForm extends Model
             $model->CID = $this->cid;
             $model->CONTENT = '';
             $model->STATUS = 1;
+            $model->SORT = $this->sort;
             if(!$model->save()){
                 throw new Exception(Form::formatErrorsForApi($model->getErrors()));
             }
@@ -96,5 +102,22 @@ class ArticleForm extends Model
         return $model;
     }
 
+    /**
+     * 排序
+     * @return Article
+     */
+    public function sortTo(): ?Article
+    {
+        if (!$this->validate()) {
+            return null;
+        }
 
+        $model = Article::findOne(['ID' => $this->id]);
+        $model->SORT = $this->sort;
+        if (!$model->save()) {
+            $this->addError('sortTo', Form::formatErrorsForApi($model->getErrors()));
+            return null;
+        }
+        return $model;
+    }
 }

+ 13 - 13
common/models/forms/OrderForm.php

@@ -88,25 +88,25 @@ class OrderForm extends Model
     public function attributeLabels()
     {
         return [
-            'sn' => '订单号',
+            'sn' => 'Order Code', // 订单号
             'expressCompany' => '快递公司',
             'orderTrackNo' => '快递单号',
-            'status' => '状态',
-            'remark' => '备注',
-            'type' => '订单类型',
+            'status' => 'State', // 状态
+            'remark' => 'Remark', // 备注
+            'type' => 'Order Type',// 订单类型
             'addressId' => 'Shipping address',// 收货地址
-            'payType' => '支付方式',
-            'goodsId' => 'product ID',//商品ID
+            'payType' => 'Pay Typa',// 支付方式
+            'goodsId' => 'Product ID',//商品ID
             'goodsNum' => 'Product quantity',//商品数量
             'userName' => 'Repeat sales Member No. does not exist',//复消会员编号
-            'consignee' => '收货人',
-            'acceptMobile' => '收货电话',
-            'province' => '省',
-            'city' => '市',
-            'county' => '区',
-            'lgaName' => 'lga name',
+            'consignee' => 'Consignee',// 收货人
+            'acceptMobile' => 'Accept Mobile',// 收货电话
+            'province' => 'Province',// 省
+            'city' => 'City',// 市
+            'county' => 'County',// 区
+            'lgaName' => 'Lga Name',
             'cityName' => 'City Name',
-            'detailaddress' => '收货详细地址',
+            'detailaddress' => 'Address',// 收货详细地址
             'email' => 'Email',
         ];
     }

+ 5 - 5
frontendEle/src/views/article/list.vue

@@ -7,11 +7,11 @@
             <router-link :to="`/article/detail/${scope.row.ID}`">{{scope.row.TITLE}}</router-link>
           </template>
         </el-table-column>
-        <el-table-column label="Classification">
-          <template slot-scope="scope">
-            {{allData.allCategory[scope.row.CID].CATE_NAME}}
-          </template>
-        </el-table-column>
+<!--        <el-table-column label="Classification">-->
+<!--          <template slot-scope="scope">-->
+<!--            {{allData.allCategory[scope.row.CID].CATE_NAME}}-->
+<!--          </template>-->
+<!--        </el-table-column>-->
         <el-table-column label="Creation Time">
           <template slot-scope="scope">
             {{tool.formatDate(scope.row.CREATED_AT)}}

+ 2 - 2
frontendEle/src/views/config/receive-address-list.vue

@@ -16,11 +16,11 @@
           </template>
         </el-table-column>
 
-        <el-table-column fixed="right" label="Edit/Delete" width="180"><!-- 操作 -->
+        <el-table-column fixed="right" label="Action" width="180"><!-- 操作 -->
           <template slot-scope="scope">
             <el-dropdown size="small" trigger="click">
               <el-button type="primary" size="small" @click.stop="">
-                Edit/Delete<!-- 操作该数据 --><i class="el-icon-arrow-down el-icon--right"></i>
+                Action<!-- 操作该数据 --><i class="el-icon-arrow-down el-icon--right"></i>
 
               </el-button>
               <el-dropdown-menu slot="dropdown">

+ 1 - 0
sql/upgrade/2022_08_05_1866.sql

@@ -0,0 +1 @@
+ALTER TABLE `AR_ARTICLE` ADD COLUMN `SORT` tinyint NOT NULL DEFAULT 10 COMMENT '排序值' AFTER `STATUS`;