check duplicate khi đồng bộ
This commit is contained in:
parent
4cb2f77598
commit
ed4b8a0144
|
@ -97,8 +97,10 @@ class ApiController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function actionData() {
|
public function actionData() {
|
||||||
|
if (Yii::$app->request->post()) {
|
||||||
Yii::$app->response->format = "json";
|
Yii::$app->response->format = "json";
|
||||||
return ListManagement::find()->orderBy(['id' => SORT_DESC])->all();
|
return ListManagement::find()->andWhere(["NOT IN", "name", Yii::$app->request->post()])->orderBy(['id' => SORT_DESC])->all();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function actionFullData() {
|
public function actionFullData() {
|
||||||
|
|
|
@ -236,12 +236,18 @@ class ListManagementController extends Controller {
|
||||||
public function actionFormSync() {
|
public function actionFormSync() {
|
||||||
if (Yii::$app->request->post()) {
|
if (Yii::$app->request->post()) {
|
||||||
$data = Yii::$app->request->post();
|
$data = Yii::$app->request->post();
|
||||||
$results = file_get_contents("http://" . $data['ip'] . "/api/data");
|
$results = json_decode(file_get_contents("http://" . $data['ip'] . "/api/data", false, stream_context_create([
|
||||||
|
'http' => [
|
||||||
|
'header' => "Content-Type: application/json",
|
||||||
|
'method' => "POST",
|
||||||
|
'content' => json_encode(ListManagement::nameArray())
|
||||||
|
]
|
||||||
|
])), true);
|
||||||
Yii::$app->response->format = "json";
|
Yii::$app->response->format = "json";
|
||||||
return [
|
return [
|
||||||
"title" => $data['ip'],
|
"title" => $data['ip'],
|
||||||
"form" => $this->renderPartial("list", [
|
"form" => $this->renderPartial("list", [
|
||||||
"results" => json_decode($results, true),
|
"results" => $results,
|
||||||
"typeArray" => ListManagement::$typeArray,
|
"typeArray" => ListManagement::$typeArray,
|
||||||
"ip" => $data['ip']
|
"ip" => $data['ip']
|
||||||
])
|
])
|
||||||
|
|
|
@ -83,4 +83,13 @@ class ListManagement extends \yii\db\ActiveRecord {
|
||||||
"Female" => "Female"
|
"Female" => "Female"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public static function nameArray() {
|
||||||
|
$res = [];
|
||||||
|
$ls = self::find()->all();
|
||||||
|
foreach ($ls as $key => $value) {
|
||||||
|
$res[] = $value->name;
|
||||||
|
}
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -316,6 +316,10 @@ function _sync(e) {
|
||||||
$.each($("#sync-lists").find(".success"), function () {
|
$.each($("#sync-lists").find(".success"), function () {
|
||||||
lists.push($(this).attr("data-id"));
|
lists.push($(this).attr("data-id"));
|
||||||
});
|
});
|
||||||
|
if (lists.length == 0) {
|
||||||
|
alert("Không có dữ liệu đồng bộ!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
common.modalBlock(true);
|
common.modalBlock(true);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: $(e).attr("data-href"),
|
url: $(e).attr("data-href"),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user