Browse Source

選取option 增加分類、搜尋

main
10994015 1 year ago
committed by Cheng
parent
commit
c9f94a4301
  1. 59
      wms/mkt/assets/js/alpine.js
  2. 161
      wms/mkt/pricereview-create.php

59
wms/mkt/assets/js/alpine.js

@ -191,3 +191,62 @@ const priceOptionSelect = ()=>{
} }
} }
} }
const pricereviewOptionSelect = ()=>{
return {
init(){
console.log(options);
this.optionCategory = 0
this.initButtons();
},
options: options,
optionalArr: {
1:'標配',
2:'選配',
3:'加價',
},
kind:0,
subkind:0,
buttons:[],
initButtons(kind){
if(kind == 'A'){
this.buttons = [
{name: '車廂意匠', type: 'A1'}
]
}else if(kind == 'B'){
this.buttons = [
{name: '天井', type: 'B1'},
{name: '地板', type: 'B2'},
{name: '操縱盤', type: 'B3'},
{name: '扶手', type: 'B4'},
{name: '車廂門與層門(轎門/層門)', type: 'B5'},
{name: '轎壁(車廂側板)', type: 'B6'},
{name: '其他車廂內裝配件', type: 'B7'},
]
}else if(kind == 'C'){
this.buttons = [
{name: '框', type: 'C1'},
{name: '乘場指示器', type: 'C2'},
{name: '燈', type: 'C3'},
{name: '方式與門', type: 'C4'},
]
}else if(kind == 'D'){
this.buttons = [
{name: '功能與配置', type: 'D1'},
{name: 'OH與樓高', type: 'D2'},
]
}else if(kind == 'E'){
this.buttons = [
{name: '平台梯', type: 'E1'},
]
}
},
kind:0,
optionSubCategory:1,
changeCategory(category){
this.kind = category
this.initButtons(category)
},
}
}

161
wms/mkt/pricereview-create.php

@ -1,6 +1,6 @@
<?php <?php
include "../header.php"; include "../header.php";
require_once('./conn.php');
$vol_no = $_REQUEST["vol_no"]; // 從有望客戶過來:卷號 $vol_no = $_REQUEST["vol_no"]; // 從有望客戶過來:卷號
// 營業員只建自己客戶的價審單 // 營業員只建自己客戶的價審單
@ -144,9 +144,9 @@ while ($row = mysqli_fetch_assoc($res)) {
$opt_data_arr[$row["kind"]][$row["group_name"]][$row["id"]]["unit"] = $row["unit"]; $opt_data_arr[$row["kind"]][$row["group_name"]][$row["id"]]["unit"] = $row["unit"];
$opt_data_arr[$row["kind"]][$row["group_name"]][$row["id"]]["price"] = $row["price"]; $opt_data_arr[$row["kind"]][$row["group_name"]][$row["id"]]["price"] = $row["price"];
} }
$option_str = $opt_data_arr[$row["kind"]][$row["group_name"]][$row["id"]]["spec"];
mysqli_free_result($res); mysqli_free_result($res);
$option_str .= '<table id="table_index2" class="table table-striped table-bordered" style="width:100%">'; $option_str = '<table id="table_index2" class="table table-striped table-bordered" style="width:100%">';
$option_str .= '<thead> $option_str .= '<thead>
<tr class="kind-col"> <tr class="kind-col">
<th scope="col" nowrap>名稱</th> <th scope="col" nowrap>名稱</th>
@ -195,6 +195,8 @@ foreach ($opt_data_arr as $k => $v) {
*/ */
} }
$option_str .= "</tbody></table>"; $option_str .= "</tbody></table>";
?> ?>
<style> <style>
.c_iframe iframe { .c_iframe iframe {
@ -242,7 +244,7 @@ $option_str .= "</tbody></table>";
} }
.modal-content { .modal-content {
height: 660px; height: 710px;
} }
#optionModal .modal-body { #optionModal .modal-body {
@ -322,6 +324,7 @@ $option_str .= "</tbody></table>";
} }
</style> </style>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script defer src="../contract/js/alpinejs/cdn.min.js"></script>
<script> <script>
// 加千分位 // 加千分位
function commafy(num) { function commafy(num) {
@ -740,7 +743,8 @@ $option_str .= "</tbody></table>";
$("#optionModal .modal-body td").unbind().click(function() { $("#optionModal .modal-body td").unbind().click(function() {
var pobj = $(this).closest('td').parent(); var pobj = $(this).closest('td').parent();
console.log(jobj.html(pobj.find('td').eq(0).html() + ' ' + pobj.find('td').eq(1).html())); console.log(jobj.html(pobj.find('td').eq(0).html() + ' ' + pobj.find('td').eq(1).html()));
jobj.html(pobj.find('td').eq(0).html() + ' ' + pobj.find('td').eq(1).html()); console.log(pobj.find('td').eq(0).html()+ pobj.find('td').eq(2).html() + ' ' + pobj.find('td').eq(1).html());
jobj.html(pobj.find('td').eq(0).html() + ' ' + pobj.find('td').eq(1).html() + '<br />(' + pobj.find('td').eq(2).html() + ')');
jobj.closest('td').parent().find('input[name=option_unit_price]').val(pobj.find('td').eq(5).html()); jobj.closest('td').parent().find('input[name=option_unit_price]').val(pobj.find('td').eq(5).html());
jobj.closest('td').parent().find('input[name=option_price_bp]').val(commafy(pobj.find('td').eq(5).html().replace(/[,]+/g, "") * jobj.closest('td').parent().find('input[name=option_qty]').val().replace(/[,]+/g, ""))); jobj.closest('td').parent().find('input[name=option_price_bp]').val(commafy(pobj.find('td').eq(5).html().replace(/[,]+/g, "") * jobj.closest('td').parent().find('input[name=option_qty]').val().replace(/[,]+/g, "")));
jobj.closest('td').parent().find('input[name=op_id]').val(pobj.find('input[name=option_id]').val()); jobj.closest('td').parent().find('input[name=op_id]').val(pobj.find('input[name=option_id]').val());
@ -1139,6 +1143,14 @@ $option_str .= "</tbody></table>";
}); });
}); });
</script> </script>
<?php
require_once('./conn.php');
$sql_str = "SELECT * FROM option_price WHERE status='Y' ORDER BY kind ASC";
$stmt = $conn->prepare($sql_str);
$stmt->execute();
$options = $stmt->fetchAll(PDO::FETCH_ASSOC);
?>
<div> <div>
<ul class="notice"> <ul class="notice">
<li>「保存」:儲存價審單內容</li> <li>「保存」:儲存價審單內容</li>
@ -1167,59 +1179,60 @@ $option_str .= "</tbody></table>";
</div> </div>
</div> </div>
<!--子窗:option加價--> <!--子窗:option加價-->
<?php <div class="modal fade" id="optionModal" tabindex="-1" role="dialog" aria-labelledby="optionModalTitle" aria-hidden="true" x-data=pricereviewOptionSelect()>
$sql_str = "SELECT * FROM option_price WHERE status='Y' ORDER BY kind ASC"; <div class="modal-dialog" role="document">
$stmt = $conn->prepare($sql_str); <div class="modal-content">
$stmt->execute(); <div class="modal-header">
$options = $stmt->fetchAll(PDO::FETCH_ASSOC); <h4 class="modal-title" id="optionModalTitle">OPTION加價</h4>
?> <button type="button" class="close" data-dismiss="modal" aria-label="Close">
<div class="modal fade" id="optionModal" tabindex="-1" role="dialog" aria-labelledby="optionModalTitle" aria-hidden="true"> <span aria-hidden="true">&times;</span>
<div class="modal-dialog" role="document"> </button>
<div class="modal-content"> <label for="" >
<div class="modal-header"> <input type="text" class="form-control" style="float:left" placeholder="搜尋..." />
<h4 class="modal-title" id="optionModalTitle">OPTION加價</h4> </label>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> <div class="categories">
<span aria-hidden="true">&times;</span> <button :class="['btn', (kind==0) ? 'btn-primary' : 'btn-secondary text-light']" @click="">顯示全部</button>
</button> <button :class="['btn', (kind=='A') ? 'btn-primary' : 'btn-secondary text-light']" @click="changeCategory('A')">A-1 車廂意匠</button>
</div> <button :class="['btn', (kind=='B') ? 'btn-primary' : 'btn-secondary text-light']">A-2 車廂內裝</button>
<div class="modal-body"> <button :class="['btn', (kind=='C') ? 'btn-primary' : 'btn-secondary text-light']">A-3 車廂外部</button>
<table id="table_index2" class="table table-striped table-bordered" style="width:100%"> <button :class="['btn', (kind=='D') ? 'btn-primary' : 'btn-secondary text-light']">A-4 控制與其他</button>
<thead> <button :class="['btn', (kind=='E') ? 'btn-primary' : 'btn-secondary text-light']">B-1 平台梯</button>
<tr class="kind-col"> <button :class="['btn', (kind=='F') ? 'btn-primary' : 'btn-secondary text-light']">C-1 汰改</button>
<th scope="col" nowrap>名稱</th> <br /><br />
<th scope="col" nowrap>規格</th> <template x-for="button in buttons" >
<th scope="col" nowrap>備註</th> <button :class="['btn', (kind==button) ? 'btn-primary' : 'btn-secondary text-light']" @click="kind=button">
<th scope="col" nowrap>配置</th> </template>
<th scope="col" nowrap>單位</th>
<th scope="col" nowrap>定價</th> </div>
</tr> </div>
</thead> <div class="modal-body" >
<tbody> <table id="" class="table table-striped table-bordered" style="width:100%">
<?php foreach($options as $option): ?> <thead>
<tr> <tr class="kind-col">
<td><?php echo $option['group_name'] ?></td> <th scope="col" nowrap>名稱</th>
<td><?php echo $option['spec']; ?></td> <th scope="col" nowrap>規格</th>
<td><?php echo $option['memo'] ?></td> <th scope="col" nowrap>備註</th>
<td><?php <th scope="col" nowrap>配置</th>
if($option['optional'] == 1){ <th scope="col" nowrap>單位</th>
echo "標配"; <th scope="col" nowrap>定價</th>
}elseif($option['optional'] == 2){ </tr>
echo "選配"; </thead>
}elseif($option['optional'] == 3){ <tbody>
echo "加價"; <template x-for="option in options" >
}else{ <tr style="cursor:pointer">
echo ""; <td x-text="option.group_name"> </td>
} <td x-text="option.spec"></td>
?></td> <td x-text="option.memo"></td>
<td><?php echo $option['unit']; ?></td> <td x-text="optionalArr[option.optional]"></td>
<td>$<?php echo $option['price']; ?></td> <td x-text="option.unit"></td>
</tr> <td x-text="option.price"></td>
<?php endforeach; ?> </tr>
</tbody> </template>
</table> </tbody>
</div> </table>
</div>
</div>
</div> </div>
</div>
</div> </div>
<!--子窗:option關連電梯--> <!--子窗:option關連電梯-->
<div class="modal fade" id="optionFaciModal" tabindex="-1" role="dialog" aria-labelledby="optionFaciModalTitle" aria-hidden="true"> <div class="modal fade" id="optionFaciModal" tabindex="-1" role="dialog" aria-labelledby="optionFaciModalTitle" aria-hidden="true">
@ -1857,10 +1870,11 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){
<?php <?php
if (count($last_pritem_arr) > 0 && isset($last_pritem_arr["B"])) { if (count($last_pritem_arr) > 0 && isset($last_pritem_arr["B"])) {
foreach ($last_pritem_arr["B"] as $k => $v) { foreach ($last_pritem_arr["B"] as $k => $v) {
print_r($last_pritem_arr);
?> ?>
<tr name="option_templ"> <tr name="option_templ">
<td name="option_seat"> <td name="option_seat">
<a href="" name="option_href" data-toggle="modal"><?php echo $v["item_spec"] . '-(' . $v['item-memo'] . ')'; ?></a> <a href="" name="option_href" data-toggle="modal"><?php echo $v["item_spec"] . '-(' . $v['item_memo'] . ')'; ?></a>
</td> </td>
<td><input type="text" name="option_unit_price" class="form-control dollar-right" size="8" value="<?php echo number_format($v["item_unit_price"]); ?>" readonly></td> <td><input type="text" name="option_unit_price" class="form-control dollar-right" size="8" value="<?php echo number_format($v["item_unit_price"]); ?>" readonly></td>
<td><input type="text" name="option_qty" class="form-control" size="2" maxlength="2" value="<?php echo $v["item_qty"]; ?>"></td> <td><input type="text" name="option_qty" class="form-control" size="2" maxlength="2" value="<?php echo $v["item_qty"]; ?>"></td>
@ -2352,22 +2366,21 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){
</tr> </tr>
</tbody> </tbody>
</table> </table>
<ul>
<li>營業權限85%以上;85-80%呈至區處長審核;80%以下呈至總經理審核。</li>
</ul>
</div> </div>
<div class="nextline"></div> <div class="nextline"></div>
<ul> <label for="attatch1">報價單</label>
<li>營業權限85%以上;85-80%呈至區處長審核;80%以下呈至總經理審核。</li> <input type="file" name="attatch1" id="attatch1"><a href="javascript:void(0);" name="filedel" class="btn btn-danger btn-sm">X</a>
</ul> <div class="nextline"></div>
<div class="nextline"></div> <label for="attatch2">附表一</label>
<label for="attatch1">報價單</label> <input type="file" name="attatch2" id="attatch2"><a href="javascript:void(0);" name="filedel2" class="btn btn-danger btn-sm">X</a>
<input type="file" name="attatch1" id="attatch1"><a href="javascript:void(0);" name="filedel" class="btn btn-danger btn-sm">X</a> <div class="nextline"></div><br>
<div class="nextline"></div> <button type="submit" name="save" id="save" value="save">保存</button>&nbsp;
<label for="attatch2">附表一</label> <button type="submit" name="submit" id="submit" value="tosign">提交</button>
<input type="file" name="attatch2" id="attatch2"><a href="javascript:void(0);" name="filedel2" class="btn btn-danger btn-sm">X</a>
<div class="nextline"></div><br>
<button type="submit" name="save" id="save" value="save">保存</button>&nbsp;
<button type="submit" name="submit" id="submit" value="tosign">提交</button>
<input type="hidden" name="fp_id_all" id="fp_id_all"> <input type="hidden" name="fp_id_all" id="fp_id_all">
<input type="hidden" name="fp_kind_all" id="fp_kind_all"> <input type="hidden" name="fp_kind_all" id="fp_kind_all">
@ -2423,3 +2436,9 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){
<?php <?php
include "../footer.php"; include "../footer.php";
?> ?>
<script src="./assets/js/alpine.js"></script>
<script>
const options = [...<?php echo json_encode($options); ?>];
</script>
Loading…
Cancel
Save