瀏覽代碼

Modification d'un document : supprimer un productOrder #166

refactoring
Guillaume Bourgeois 4 年之前
父節點
當前提交
2e628a163b
共有 3 個檔案被更改,包括 33 行新增2 行删除
  1. +20
    -0
      backend/controllers/DocumentController.php
  2. +4
    -2
      backend/views/document/_form.php
  3. +9
    -0
      backend/web/js/vuejs/document-form.js

+ 20
- 0
backend/controllers/DocumentController.php 查看文件

@@ -246,6 +246,26 @@ class DocumentController extends BackendController
'return' => 'error'
] ;
}

public function actionAjaxDeleteProductOrder($idProductOrder)
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

$productOrder = ProductOrder::searchOne([
'id' => $idProductOrder
]) ;

if($productOrder) {
$productOrder->delete() ;
return [
'return' => 'success'
] ;
}

return [
'return' => 'error'
] ;
}
protected function getClass()
{

+ 4
- 2
backend/views/document/_form.php 查看文件

@@ -193,8 +193,10 @@ use common\models\Producer;
<td>{{ formatPrice(productOrder.quantity *
productOrder.price) }}
</td>
<td><a class="btn btn-default"><span
class="glyphicon glyphicon-trash"></span></a>
<td>
<a class="btn btn-default" @click="deleteProductOrder(productOrder.id)">
<span class="glyphicon glyphicon-trash"></span>
</a>
</td>
</tr>
</template>

+ 9
- 0
backend/web/js/vuejs/document-form.js 查看文件

@@ -123,6 +123,15 @@ var app = new Vue({
app.init() ;
alert('Produit ajouté') ;
}) ;
},
deleteProductOrder: function(idProductOrder) {
var app = this ;
axios.get(UrlManager.getBaseUrlAbsolute()+"document/ajax-delete-product-order",{params: {
idProductOrder: idProductOrder
}})
.then(function(response) {
app.init() ;
}) ;
}
}
});

Loading…
取消
儲存