Pārlūkot izejas kodu

Modification d'un document : supprimer un productOrder #166

dev
Guillaume Bourgeois pirms 4 gadiem
vecāks
revīzija
2e628a163b
3 mainītis faili ar 33 papildinājumiem un 2 dzēšanām
  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 Parādīt failu

@@ -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 Parādīt failu

@@ -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 Parādīt failu

@@ -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() ;
}) ;
}
}
});

Notiek ielāde…
Atcelt
Saglabāt