采购订单(PO)问题集


1 .datatables.js:77990 Uncaught TypeError: Cannot read property 'style' of undefined
     at _fnCalculateColumnWidths (datatables.js:77990)
     at _fnInitialise (datatables.js:77104)
     at loadedInit (datatables.js:73683)
     at HTMLTableElement.<anonymous> (datatables.js:73695)
     at Function.each (datatables.js:366)
     at jQuery.fn.init.each (datatables.js:201)
     at jQuery.fn.init.DataTable [as dataTable] (datatables.js:73258)
     at jQuery.fn.init.$.fn.DataTable (datatables.js:87512)
     at potestajaxedittab:32

答:columns:[

{
data: null,
defaultContent: '',
className: 'select-checkbox',
orderable: false
},
2. 如何在po(订单)中回显供应商名称
  答:https://blog.csdn.net/qq_35123187/article/details/79986039

3..如何按供应商关键值进行搜索

<li>供应商名称:
<select id="supname" name="supname" class="js-example-matcher">
<option th:each="sup:${supplier}" th:value="${sup.supName}" th:text="${sup.supName}" ></option>
</select>
</li>

  https://select2.org/searching#customizing-how-results-are-matched

function matchCustom(params, data) {
if ($.trim(params.term) === '') {
return data;
}
if (typeof data.text === 'undefined') {
return null;
}
if (data.text.indexOf(params.term) > -1) {
var modifiedData = $.extend({}, data, true);
modifiedData.text += '';
return modifiedData;
}
return null;
}
$(".js-example-matcher").select2({
matcher: matchCustom
});
最终解决方案:(老牛)
<script type="text/javascript" src="/ajax/libs/jquery-ui/jquery-ui.js"></script>
<link rel="stylesheet" href="/ajax/libs/jquery-ui/jquery-ui.css"/>
<script type="text/javascript">
$(function() {
$("#supName").autocomplete({
autoFocus: true,
minLength: 0,
source: function (request, response) {
$.post(
'/basic/supplier/search',
{
'supName': $("#supName").val(),
'supCode': $("#supName").val(),
'mnemonic': $("#supName").val()
}, function (data) {
response($.map(data.rows, function (item) {
return {value: item.supCode, label: item.supName};
}));
})
},
select: function (event, ui) {
// $("#supName").val(ui.item.label);
// $("#supCode").val(ui.item.value);
return false;
}
})
})
4.如何得到默认值 
5.如何得到二级联动下拉菜单(如依据供应商,选择联系人)
  所涉及知识点
参数

$.post(url,[data],[fn],[type]

url,[data],[callback],[type]String,Map,Function,StringV1.0

url:发送请求地址。

data:待发送 Key/value 参数。

callback:发送成功时回调函数。

type:返回内容格式,xml, html, script, json, text, _default。

$.map(arr|obj,callback)

返回值

Array

概述

将一个数组中的元素转换到另一个数组中。

参数

array:待转换数组。

callbackArray:为每个数组元素调用,而且会给这个转换函数传递一个表示被转换的元素作为参数。函数可返回任何值。另外,此函数可设置为一个字符串,当设置为字符串时,将视为“lambda-form”(缩写形式?),其中 a 代表数组元素。如“a * a”代表“function(a){ return a * a; }”

select( event, ui )Type: autocompleteselect (组件)

Triggered when an item is selected from the menu. The default action is to replace the text field's value with the value of the selected item.

Canceling this event prevents the value from being updated, but does not prevent the menu from closing.

  • event

    Type: Event

  • ui

    Type: Object

    • item

      Type: Object

      An Object with label and value properties for the selected option.

Code examples:

Initialize the autocomplete with the select callback specified:

1

2

3

$( ".selector" ).autocomplete({

select: function( event, ui ) {}

});

Bind an event listener to the autocompleteselect event:

1


$( ".selector" ).on( "autocompleteselect", function( event, ui ) {} );

mysql子查询

二、mysql子查询

1、where型子查询

(把内层查询结果当作外层查询的比较条件)

                #不用order by 来查询最新的商品

                select goods_id,goods_name from goods where goods_id = (select max(goods_id) from goods);

                #取出每个栏目下最新的产品(goods_id唯一)

                select cat_id,goods_id,goods_name from goods where goods_id in(select max(goods_id) from goods group by cat_id);

2、from型子查询

(把内层的查询结果供外层再次查询)

                #用子查询查出挂科两门及以上的同学的平均成绩

                    思路:

                        #先查出哪些同学挂科两门以上

                        select name,count(*) as gk from stu where score < 60 having gk >=2;

                        #以上查询结果,我们只要名字就可以了,所以再取一次名字

                        select name from (select name,count(*) as gk from stu having gk >=2) as t;

                        #找出这些同学了,那么再计算他们的平均分

                        select name,avg(score) from stu where name in (select name from (select name,count(*) as gk from stu having gk >=2) as t) group by name;

3、exists型子查询

(把外层查询结果拿到内层,看内层的查询是否成立)

                #查询哪些栏目下有商品,栏目表category,商品表goods

                    select cat_id,cat_name from category where exists(select * from goods where goods.cat_id = category.cat_id);

最终方案:(老牛指导)

前台:

//联系人
$('#contactName').focus(function(){
$(this).autocomplete("search", "");
});
$("#contactName").autocomplete({
autoFocus: true,
minLength: 0,
source: function (request, response) {
$.post(
'/basic/contacts/listbysupcusname',
{
supcusname:$("#supName").val()---supcusname和后台形参对应,否则出错!
},
function (data) {
response($.map(data.rows, function (item) {
return {value: item.contactName, label: item.contactName};
}));

if(data.total > 0){
$("#contactName").val(data.rows[0].contactName);
}
})
},
select: function (event, ui) {
$("#contactName").val(ui.item.value);
return true;
}
});
后台:
/**
* 根据往来单位名称查询联系人列表
*/
@RequiresPermissions("basic:contacts:listbysupcusname")
@PostMapping("/listbysupcusname")
@ResponseBody
public TableDataInfo listBySupcusname(String supcusname ){
//startPage();
//判断当前用户是否为普通用户 如果是普通用户 不能看到删除数据
List<Contacts> ContactsList= contactsService.selectContactsListBySupName(supcusname);
System.out.println("=================list+"+ContactsList);
return getDataTable(ContactsList);
}
ContactsMapper.xml
<!--依据往来单位名称查询-->
<select id="selectContactsListBySupcusName" parameterType="String"
resultMap="ContactsnameResult">
select cont.contact_name
from basic_contacts cont,basic_supplier sup
where cont.supcus_id= sup.sup_code and sup.sup_name=#{sup.supName}
</select>
结果:image

猜你喜欢

转载自www.cnblogs.com/elite-2012/p/10670307.html