Cheng 1 year ago
parent
commit
18aca7810f
  1. 40
      wms/T8_APItest.php
  2. 4
      wms/T8_Authorization_from_bpm.php
  3. 40
      wms/contract/api/postContractData.php
  4. 163
      wms/contract/api/testT8API.php
  5. 6
      wms/contract/js/alpine.js

40
wms/T8_APItest.php

@ -33,22 +33,40 @@ echo "ii";
"DtOrgId": "1000", "DtOrgId": "1000",
"DueToId": "B23100061", "DueToId": "B23100061",
"TaxId": "ST005", "TaxId": "ST005",
"CompId": "1001" "CompId": "1001",
"CreatorId": "M0225"
}] }]
}, },
{ {
"name": "salIncomeApplyDetail", "name": "salIncomeApplyDetail",
"rows": [{ "rows": [{
"BillNo": "B23100061", "BillNo": "B23100061",
"IncomeId": "A40004", "IncomeId": "A40004",
"TaxId": "ST005", "TaxId": "ST005",
"RowCode": 1, "RowCode": 1,
"ItemType": "1", "RowNo": 1,
"SPrice": 10000, "ItemType": "1",
"SQuantity": 0, "SPrice": 10000,
"FromSourceTag": 0, "SQuantity": 2,
"FromBillNo": "" "ProjectId": "B23100061",
}] "FromSourceTag": 0,
"CU_MaterialId": "3MH00112"
},
{
"BillNo": "B23100061",
"IncomeId": "A40004",
"TaxId": "ST005",
"RowCode": 2,
"RowNo": 2,
"ItemType": "1",
"SPrice": 10000,
"SQuantity": 2,
"ProjectId": "B23100061",
"FromSourceTag": 0,
"CU_MaterialId": "3MH00112"
}
],
} }
]; ];
var json = JSON.stringify(body); var json = JSON.stringify(body);

4
wms/T8_Authorization_from_bpm.php

@ -32,8 +32,8 @@ function get_Auth($user_id = "M0000", $user_password = "M012290493119")
if ($response === false) { if ($response === false) {
echo 'Curl error: ' . curl_error($ch); echo 'Curl error: ' . curl_error($ch);
} else { } else {
// print_r($response); print_r($response);
// exit; exit;
$result = json_decode($response, true); $result = json_decode($response, true);
$validation = $result['Data']['CHI_Authorization']; $validation = $result['Data']['CHI_Authorization'];
return $validation; return $validation;

40
wms/contract/api/postContractData.php

@ -344,7 +344,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
function T8insert($data, $facilityno) function T8insert($data, $facilityno)
{ {
require_once("../connt8.php"); require_once("../connt8.php");
// include "../../T8_Authorization.php"; include "../../T8_Authorization.php";
$contractno = !empty($data['contractno']) ? $data['contractno'] : null; // 合約號 $contractno = !empty($data['contractno']) ? $data['contractno'] : null; // 合約號
$address = !empty($data['address']) ? $data['address'] : null; // 客戶地址 $address = !empty($data['address']) ? $data['address'] : null; // 客戶地址
@ -360,6 +360,7 @@ function T8insert($data, $facilityno)
$num = !empty($data['num']) ? $data['num'] : null; // 電梯數量 $num = !empty($data['num']) ? $data['num'] : null; // 電梯數量
$elevators = !empty($data['elevators']) ? json_decode($data['elevators'], true) : []; //電梯 $elevators = !empty($data['elevators']) ? json_decode($data['elevators'], true) : []; //電梯
$area = !empty($data['area']) ? $data['area'] : null; //縣市 Ex. A->台北 , B-> ..。 $area = !empty($data['area']) ? $data['area'] : null; //縣市 Ex. A->台北 , B-> ..。
$payType = !empty($data['payType']) ? $data['payType'] : null;
$user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null; $user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null;
@ -372,7 +373,9 @@ function T8insert($data, $facilityno)
$stmt->execute(); $stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC); $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
$date = date('Y-m-sH-s-i'); $date = date('Y-m-sH-s-i');
$date_1 = date('Y-m-sH-s');
$createTime = str_replace("-", '', $date); $createTime = str_replace("-", '', $date);
$insertTime = str_replace('-', '', $date_1);
$beginDate = str_replace("-", '', $contract_begin_date); $beginDate = str_replace("-", '', $contract_begin_date);
$endDate = str_replace("-", '', $contract_end_date); $endDate = str_replace("-", '', $contract_end_date);
if ($contractno == '') { if ($contractno == '') {
@ -481,7 +484,6 @@ function T8insert($data, $facilityno)
$stmt->bindParam(':CreatorId', $user_id); $stmt->bindParam(':CreatorId', $user_id);
$stmt->execute(); $stmt->execute();
// // 新增電梯數 // // 新增電梯數
foreach ($elevators as $index => $elevator) { foreach ($elevators as $index => $elevator) {
// echo '<pre>'; // echo '<pre>';
@ -515,36 +517,12 @@ function T8insert($data, $facilityno)
$stmt->bindParam(':CreatorId', $user_id); $stmt->bindParam(':CreatorId', $user_id);
$stmt->bindParam(':CreateTime', $createTime); $stmt->bindParam(':CreateTime', $createTime);
$stmt->execute(); $stmt->execute();
}
?> ?>
<!-- <script src="./js/axios/axios.min.js"></script> <script>
<script>
const form = new FormData(); </script>
form.append('BillNo', <?php echo $contractno ?>);
form.append('BillDate', );
form.append('');
form.append('');
form.append('');
form.append('');
form.append('');
axios.post('https://127.0.0.1:780/twWebAPI/V1/SALINCOMEAPPLY/PostERPData', form).then(res => {
console.log(res.status);
if (res.status == 200) {
alert('成功');
}
}).catch(err => {
console.log(err);
let code = err.response.data;
if (code == 422) {
console.log(err);
}
if (code == 500) {
alert('儲存失敗!可能為下載錯誤:\n' + error.response.data);
}
})
</script> -->
<?php <?php
}
$connT8->commit(); $connT8->commit();
} }

163
wms/contract/api/testT8API.php

@ -2,76 +2,107 @@
$now = gmdate("YmdHis"); $now = gmdate("YmdHis");
$data = 'M0000.' . $now; $data = 'M0000.' . $now;
$sign = hash_hmac('SHA256', $data, 'B2D6395D2883E26C', false); $sign = hash_hmac('SHA256', $data, 'B2D6395D2883E26C', false);
$test = [
"A40005" => 2,
"A40001" => 3,
"A40002" => 4,
];
echo '<pre>';
print_r($test['A40001']);
echo '</pre>';
$payType = 'A0005';
?> ?>
<script src="https://code.jquery.com/jquery-3.4.1.js" integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU=" crossorigin="anonymous"></script> <script src="https://code.jquery.com/jquery-3.4.1.js" integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU=" crossorigin="anonymous"></script>
<script> <script>
var body = [{ // var body = [{
"name": "salIncomeApplyMaster", // "name": "salIncomeApplyMaster",
"rows": [{ // "rows": [{
"BillNo": "Z001", // "BillNo": "Z001",
"BillDate": 20160811, // "BillDate": 20160811,
"OrgId": "1000", // "OrgId": "1000",
"FOrgId": "1000", // "FOrgId": "1000",
"TypeId": "RR", // "TypeId": "RR",
"BpOrgId": "1000", // "BpOrgId": "1000",
"BizPartnerId": "C002", // "BizPartnerId": "C002",
"CurrId": "RMB", // "CurrId": "RMB",
"CurrOAmount": 1, // "CurrOAmount": 1,
"CurrLAmount": 1, // "CurrLAmount": 1,
"PersonId": "T001", // "PersonId": "T001",
"DtOrgId": "1000", // "DtOrgId": "1000",
"DueToId": "C002", // "DueToId": "C002",
"TaxId": "123", // "TaxId": "123",
"CompId": "1000" // "CompId": "1000"
}] // }]
}, // },
{ // {
"name": "salIncomeApplyDetail", // "name": "salIncomeApplyDetail",
"rows": [{ // "rows": [{
"BillNo": "Z001", // "BillNo": "Z001",
"IncomeId": "F203", // "IncomeId": "F203",
"TaxId": "ST003", // "TaxId": "ST003",
"RowCode": 1, // "RowCode": 1,
"ItemType": "1", // "ItemType": "1",
"SPrice": 50, // "SPrice": 50,
"SQuantity": 1, // "SQuantity": 1,
"FromSourceTag": 0, // "FromSourceTag": 0,
"FromBillNo": "123" // "FromBillNo": "123"
}] // }]
} // }
] // ]
var json = JSON.stringify(body); // var json = JSON.stringify(body);
console.log(json); // console.log(json);
// obj = { // // obj = {
// type: 'POST', // // type: 'POST',
// // url: `${corsurl}${apiurl}`, // // // url: `${corsurl}${apiurl}`,
// url: `${apiurl}`, // // url: `${apiurl}`,
// dataType: 'json', // // dataType: 'json',
// headers: headerParam, // // headers: headerParam,
// data: json, // // data: json,
// // dataType: "json", // // // dataType: "json",
// success: function(res) { // // success: function(res) {
// console.log(res.Status); // // console.log(res.Status);
// console.log(res.ErrorMsg); // // console.log(res.ErrorMsg);
// console.log(res.Data); // // console.log(res.Data);
// } // // }
// }; // // };
// jQuery.ajax(obj); // // jQuery.ajax(obj);
// // } // // // }
// // })
// $.ajax({
// url: 'https://127.0.0.1:780/twWebAPI/V1/SALINCOMEAPPLY/PostERPData',
// method: 'POST',
// dataType: 'json',
// // headers: headerParam,
// data: body,
// success: function(res) {
// console.log('Success');
// },
// error: function(err) {
// console.log(err);
// }
// }) // })
$.ajax({ let No = 'B123';
url: 'https://127.0.0.1:780/twWebAPI/V1/SALINCOMEAPPLY/PostERPData', let arr = [];
method: 'POST', for (let i = 1; i < 5; i++) {
dataType: 'json', let obj = {
// headers: headerParam, 'No': No,
data: body, 'name': '12344',
success: function(res) { 'mum': i
console.log('Success'); };
}, // let arr = [];
error: function(err) { arr.push(obj);
console.log(err); }
} console.log(JSON.stringify(arr));
})
let obj = {
'A0004': 3,
'A0005': 4
}
for (let i = 1; i <= obj.<?= $payType ?>; i++) {
console.log(i);
}
</script> </script>

6
wms/contract/js/alpine.js

@ -964,7 +964,7 @@ const contractInput = () => {
num: '', //電梯數量 num: '', //電梯數量
disabled: false, //資料庫是否有電梯數量資料 disabled: false, //資料庫是否有電梯數量資料
elevators: [], //機種、載重、人乘、樓停、樓層、速度、緯度、經度、開門方式、保養別、廠牌、竣檢日、許可證日期 elevators: [], //機種、載重、人乘、樓停、樓層、速度、緯度、經度、開門方式、保養別、廠牌、竣檢日、許可證日期
payType: '' payType: '' //付款方式
}, },
customize: false, customize: false,
step: 1, step: 1,
@ -1037,7 +1037,7 @@ const contractInput = () => {
this.data.disabled = (res.data.num > 0) ? true : false; this.data.disabled = (res.data.num > 0) ? true : false;
this.data.elevators = res.data.elevators this.data.elevators = res.data.elevators
let cityIndex = this.data.address.indexOf('市'); let cityIndex = this.data.address.indexOf('市');
console.log(cityIndex); // console.log(cityIndex);
if (cityIndex == -1) { if (cityIndex == -1) {
// cityIndex = this.data.address.indexOf('縣'); // cityIndex = this.data.address.indexOf('縣');
} }
@ -1122,7 +1122,7 @@ const contractInput = () => {
form.append('files[]', this.data.files[i]); form.append('files[]', this.data.files[i]);
} }
axios.post('./api/postContractData.php', form).then(res => { axios.post('./api/postContractData.php', form).then(res => {
console.log(res); // console.log(res);
if (res.status === 200) { if (res.status === 200) {
alert('儲存成功'); alert('儲存成功');
this.step = 1 this.step = 1

Loading…
Cancel
Save