123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539 |
- <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
- <div class="modal-dialog" style="width:800px">
- <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" aria-hidden="true" onclick="cel()">
- ×
- </button>
- <button type="button" class="btn btn-default btn-sm" aria-hidden="true" onclick="updatecahce()" style="float:right;margin-right: 30px;">
- 刷新
- </button>
- <h4 class="modal-title" id="myModalLabel">
- 数据录入
- </h4>
- </div>
- <div class="modal-body">
- <form role="form" id="market-form">
- <input type="hidden" name="id" id="id" value="0">
- <div class="row">
- <div class="col-md-6">
- <div class="form-group">
- <label for="name">计提月份</label>
- <select name="month" id="month" class="form-control">
- <?php
- foreach ($maonth_picker->monarr as $value) {
- if ($maonth_picker->cur_month == $value) {
- echo "<option value='$value' selected>$value</option>";
- } else {
- echo "<option value='$value'>$value</option>";
- }
- }
- ?>
- </select>
- </div>
- </div>
- <div class="col-md-6">
- <div class="form-group">
- <label for="name">公司名称</label>
- <select class="selectpicker form-control" data-live-search="true" name="company" id="company">
- <option value="">公司名称</option>
- <?php
- foreach ($data_company as $company) {
- ?>
- <option value="<?php echo $company['name'] ?>"><?php echo $company['name'] ?></option>
- <?php
- }
- ?>
- </select>
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-md-12">
- <div class="form-group">
- <label for="name">请选择要录入的数据</label>
- <select class="form-control" name="conpany_sales_data" id="conpany_sales_data">
- <option value="">请选择合同号</option>
- </select>
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-md-6">
- <div class="form-group">
- <label for="name">合同号</label>
- <input type="text" class="form-control" name="contract_no" id="contract_no" placeholder="合同号">
- </div>
- </div>
- <div class="col-md-6">
- <div class="form-group">
- <label for="name">产品类别</label>
- <input type="text" class="form-control" name="goods_category" id="goods_category" placeholder="产品类别">
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-md-6">
- <div class="form-group">
- <label for="name">产品型号</label>
- <input type="text" class="form-control" name="goods_type" id="goods_type" placeholder="产品型号">
- </div>
- </div>
- <div class="col-md-6">
- <div class="form-group">
- <label for="name">数量(KG)</label>
- <input type="number" class="form-control val_change" name="amount" id="amount" placeholder="数量">
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-md-6">
- <div class="form-group">
- <label for="name">单价</label>
- <input type="number" class="form-control val_change" name="price" id="price" placeholder="单价">
- </div>
- </div>
- <div class="col-md-6">
- <div class="form-group">
- <label for="name">合同额</label>
- <input type="number" class="form-control" name="contract_value" id="contract_value" placeholder="合同额">
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-md-6">
- <div class="form-group">
- <label for="name">代理费</label>
- <input type="number" class="form-control val_change" name="agency" id="agency" placeholder="代理费">
- </div>
- </div>
- <div class="col-md-6">
- <div class="form-group">
- <label for="name">运费</label>
- <input type="number" class="form-control val_change" name="shipping" id="shipping" placeholder="运费">
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-md-6">
- <div class="form-group">
- <label for="name">收款金额</label>
- <input type="number" class="form-control val_change" name="receive_money" id="receive_money" placeholder="收款金额">
- </div>
- </div>
- <div class="col-md-6">
- <div class="form-group">
- <label for="name">上期余额</label>
- <input type="number" class="form-control" name="period_balance" id="period_balance" placeholder="上期余额" disabled>
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-md-6">
- <div class="form-group">
- <label for="name">实收金额</label>
- <input type="number" class="form-control" name="actual_money" id="actual_money" placeholder="实收金额" disabled="true">
- </div>
- </div>
- <div class="col-md-6">
- <div class="form-group">
- <label for="name">本期结余</label>
- <input type="number" class="form-control" name="current_balance" id="current_balance" placeholder="本期结余" disabled="true">
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-md-6">
- <div class="form-group">
- <label for="name">提成类型</label>
- <label class="radio-inline">
- <input type="radio" name="type" id="type0" value="0" checked="checked" onclick="tcType(0)"> 一般
- </label>
- <label class="radio-inline">
- <input type="radio" name="type" id="type1" value="1" onclick="tcType(1)"> 特批1
- </label>
- <label class="radio-inline">
- <input type="radio" name="type" id="type2" value="2" onclick="tcType(2)"> 特批2
- </label>
- </div>
- </div>
- </div>
- <div id="yiban" class="active bj">
- <div class="row">
- <div class="col-md-6">
- <div class="form-group">
- <label for="name">基准单价</label>
- <input type="number" class="form-control val_change" name="base_price" id="base_price" placeholder="基准单价">
- </div>
- </div>
- <div class="col-md-6">
- <div class="form-group">
- <label for="name">合同基准价</label>
- <input type="number" class="form-control" name="base_value" id="base_value" placeholder="合同基准价" disabled="true">
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-md-6">
- <div class="form-group">
- <label for="name">工程费成本</label>
- <input type="number" class="form-control val_change" name="project" id="project" placeholder="工程费成本">
- </div>
- </div>
- <div class="col-md-6">
- <div class="form-group">
- <label for="name">总利润</label>
- <input type="number" class="form-control" name="total_profit" id="total_profit" placeholder="总利润" disabled="true">
- </div>
- </div>
- </div>
- </div>
- <div id="tepi" class="bj">
- <div class="row">
- <div class="col-md-6">
- <div class="form-group">
- <label for="name">公司低价</label>
- <input type="number" class="form-control val_change" name="base_price2" id="base_price2" placeholder="基准单价">
- </div>
- </div>
- <div class="col-md-6">
- <div class="form-group">
- <label for="name">实际合同额</label>
- <input type="number" class="form-control" name="actual_value" id="actual_value" placeholder="实际合同额">
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-md-4">
- <div class="form-group">
- <label for="name">价格比例</label>
- <input type="number" class="form-control" name="price_rate" id="price_rate" placeholder="价格比例" disabled="true">
- </div>
- </div>
- <div class="col-md-4">
- <div class="form-group">
- <label for="name">提成比例</label>
- <input type="number" class="form-control" name="commission_rate" id="commission_rate" placeholder="提成比例" disabled="true">
- </div>
- </div>
- <div class="col-md-4">
- <div class="form-group">
- <label for="name">提成额</label>
- <input type="number" class="form-control" name="commission_money" id="commission_money" placeholder="提成额" disabled="true">
- </div>
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-md-6">
- <div class="form-group">
- <label for="name">销售员</label>
- <input type="text" class="form-control" name="seller" id="seller" placeholder="销售员">
- </div>
- </div>
- <div class="col-md-6">
- <div class="form-group">
- <label for="name">备注</label>
- <input type="text" class="form-control" name="remark" id="remark" placeholder="备注">
- </div>
- </div>
- </div>
- <div class="row">
- </div>
- </form>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-default" onclick="cel()">关闭
- </button>
- <button type="button" class="btn btn-primary" id="tj">
- 提交
- </button>
- </div>
- </div><!-- /.modal-content -->
- </div><!-- /.modal -->
- </div>
- <script>
- var dataForm = {
- "id": 0,
- "month": "",
- "company": "",
- "contract_no": "",
- "goods_category": "",
- "goods_type": "",
- "amount": 0,
- "price": 0,
- "contract_value": 0,
- "receive_money": 0,
- "period_balance": 0,
- "agency": 0,
- "base_price": 0,
- "shipping": 0,
- "project": 0,
- "type": 0,
- "seller": "",
- "remark": ""
- };
- var salesData = getSalesData()
- var conpanySalesData = [];
- function getSalesData() {
- salesData = JSON.parse(window.localStorage.getItem('salesData'));
- return salesData;
- }
- function getContractNoByCompany(company) {
- conpanySalesData = [];
- var option = {};
- for (i=1; i < salesData.length; i++) {
- row = salesData[i];
- if (row[3] == company) {
- option.contract_no = row[12];
- option.goods_category = row[6];
- option.goods_type = row[7];
- option.amount = row[8];
- option.price = row[10];
- option.contract_value = row[11];
- option.seller = row[13];
- option.shipping = row[15];
- conpanySalesData.push(option);
- option = {};
- }
- }
- }
- function updateCompanySalesData() {
- let str = '<option value="">请选择合同数据</option>';
- conpanySalesData.forEach((e, i) => {
-
- str += '<option value="' + i + '">' + e.contract_no +','+e.goods_category+','+ e.goods_type+','+ e.amount+','+ e.price+','+ e.contract_value+'</option>';
- });
- $('#conpany_sales_data').html(str)
- }
- function updatePeriodBalance() {
- $.post('/index/commission/perbalance', {
- 'company': dataForm.company
- }, function(res) {
- if (res.code == 0) {
- dataForm.period_balance = res.data;
- $("#period_balance").val(dataForm.period_balance)
- }
- }, 'json')
- }
- $("#company").change(function() {
- dataForm.company = $(this).val();
- getContractNoByCompany(dataForm.company);
- updateCompanySalesData();
- updatePeriodBalance();
- })
- $('#conpany_sales_data').change(function(){
-
- var i = $('#conpany_sales_data').val();
- var data = conpanySalesData[i];
- dataForm.contract_no = data.contract_no;
- dataForm.goods_category = data.goods_category;
- dataForm.goods_type = data.goods_type;
- dataForm.amount = data.amount;
- dataForm.price = data.price;
- dataForm.seller = data.seller;
- dataForm.shipping = data.shipping;
- if (data.contract_value.indexOf('(') != -1) {
- var contract_value = ltrim(data.contract_value, '(');
- contract_value = rtrim(contract_value, ')');
- dataForm.contract_value = Number(-contract_value);
- } else {
- dataForm.contract_value = Number(data.contract_value);
- }
- $("#contract_no").val(dataForm.contract_no)
- $("#goods_category").val(dataForm.goods_category)
- $("#goods_type").val(dataForm.goods_type)
- $("#amount").val(Number(dataForm.amount))
- $("#price").val(Number(dataForm.price))
- if (dataForm.contract_value<0) {
- $("#contract_value").css('color', 'red');
- }
- $("#contract_value").val(dataForm.contract_value);
- $("#seller").val(dataForm.seller)
- $("#shipping").val(Number(dataForm.shipping))
- })
- function updateDataFrom() {
- dataForm.shipping = Number($("#shipping").val());
-
- var receive_money = Number($("#receive_money").val());
- dataForm.receive_money = receive_money;
- dataForm.actual_money = receive_money + dataForm.period_balance;
-
- $("#actual_money").val(dataForm.actual_money) ;
-
- dataForm.current_balance = dataForm.actual_money - dataForm.contract_value;
- $("#current_balance").val(dataForm.current_balance);
- }
- $(".val_change").change(function() {
- updateDataFrom();
- updateBaseValue();
- updateTotalProfit();
- updateTepi();
- })
- function updateBaseValue() {
- var amount = $("#amount").val();
- var base_price = $("#base_price").val();
- $("#base_value").val(amount * base_price);
- }
- function updateTotalProfit() {
- var contract_value = Number($("#contract_value").val());
- var agency = Number($("#agency").val());
- var base_value = Number($("#base_value").val());
- var shipping = Number($("#shipping").val());
- var total_profit = contract_value - agency - base_value - shipping;
- $("#total_profit").val(total_profit);
- }
- function updateTepi() {
- var base_price = Number($("#base_price2").val());
- if (dataForm.type != 0) {
- dataForm.base_price = base_price;
- var price = $("#price").val();
- var price_rate = price / base_price;
- $("#price_rate").val(price_rate);
- var contract_value = Number($("#contract_value").val());
- var agency = Number($("#agency").val());
- var actual_value = contract_value - agency;
- $("#actual_value").val(actual_value);
- var shipping = Number($("#shipping").val());
- if (dataForm.type == 1) {
- if (price_rate < 1.05) {
- dataForm.commission_rate = 0.01;
- } else if (price_rate < 1.1) {
- dataForm.commission_rate = 0.015;
- } else {
- dataForm.commission_rate = 0.02;
- }
- } else {
- dataForm.commission_rate = Math.floor((((price_rate - 1) / 0.1) * 0.01 + 0.01) * 100) / 100;
-
- }
- $("#commission_rate").val(dataForm.commission_rate);
- var commission_money = ((actual_value - shipping) * dataForm.commission_rate).toFixed(2);
- $("#commission_money").val(commission_money);
- }
- }
- function tcType(bj) {
- dataForm.type = bj;
- if (bj != 0) {
- $('#yiban').removeClass('active');
- $('#tepi').addClass('active');
- } else {
- $('#tepi').removeClass('active');
- $('#yiban').addClass('active');
- }
- }
- function updatecahce() {
- window.location.href = "/index/index/index";
- }
- function cel() {
- $('#myModal').modal('hide');
- $("#market-form")[0].reset();
- $('#company').selectpicker('deselectAll');
- }
- $("#tj").click(function() {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- type = $('input[name="type"]:checked').val();
- if (type != 0) {
- base_price = Number($('#base_price2').val());
- } else {
- base_price = Number($('#base_price').val());
- }
-
-
- var data = {
- 'id': $('#id').val(),
- 'month': $('#month').val(),
- 'company': $('#company').val(),
- 'contract_no': $('#contract_no').val(),
- 'goods_category': $('#goods_category').val(),
- 'goods_type': $('#goods_type').val(),
- 'amount': $('#amount').val(),
- 'price': $('#price').val(),
- 'contract_value': $('#amount').val() * $('#price').val(),
- 'receive_money': $('#receive_money').val(),
- 'period_balance': $('#period_balance').val(),
- 'agency': $('#agency').val(),
- 'base_price': base_price,
- 'shipping': Number($('#shipping').val()),
- 'project': Number($('#project').val()),
- 'type': type,
- 'seller': $('#seller').val()
- }
- $.ajax({
- url: "/domarket.php?action=save",
- type: "POST",
- data: data,
- dataType: 'json',
- success: function(res) {
- if (res.code == 0) {
- dataForm.id = 0;
- $('#id').val(0)
- $('#myModal').modal('hide');
- $("#market-form")[0].reset();
- window.location.reload();
- } else {
- alert(res.msg);
- }
- return false;
- }
- });
- });
- </script>
|