ApplySupplierShareScript.blade.php
3.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<script>
layui.use(['table', 'form', 'element', 'table', 'layer', 'admin'], function () {
let admin = layui.admin;
let form = layui.form;
let table = layui.table
table.render({
elem: '#applyList'
, url: '/api/supplier_share_apply/GetSupplierShareApplyList'
, method: 'post'
, size: 'sm'
, limit: 10
, cellMinWidth: 80 //全局定义常规单元格的最小宽度
, where: {}
, loading: true
, first: true //不显示首页
, last: false //不显示尾页
, cols: [[
{
field: 'supplier_name', title: '供应商名称', align: 'center', templet: function (d) {
return d.supplier ? d.supplier.supplier_name : '';
}
},
{
field: 'department_name', title: '被申请部门', width: 150, align: 'center', templet: function (d) {
return d.apply_department ? d.apply_department.department_name : '';
}
},
{field: 'create_time', title: '申请时间', width: 150, align: 'center'},
{
field: 'status_name', title: '状态', width: 150, align: 'center', templet: function (d) {
console.log(d);
if (d.status === -1 || d.status === -2) {
return "<span style='color: red'>" + d.status_name + "</span>"
} else {
return d.status_name;
}
}
},
]]
, id: 'applyList'
, page: {}
});
//点击校验按钮
$('#check_apply_supplier_share').click(function () {
let supplierName = $('#supplier_name').val();
let url = '/api/supplier_share_apply/CheckApplySupplierShare';
let data = {
supplier_name: supplierName
}
let res = ajax(url,data);
if (res.err_code === 0) {
layer.msg(res.err_msg, {icon: 6});
//设置对应的supplier_id,后端暂时放到res.count这个字段吧...
let supplierId = res.count;
$('#supplier_id').val(supplierId);
//渲染下拉框
let optionHtml = '<option value="">请选择一个部门</option>';
$.each(res.data, function (index, value) {
optionHtml += "<option value='" + value.department_id + "'>" + value.department_name + "</option>"
})
$('#apply_department_id').html(optionHtml);
form.render('select');
} else {
layer.msg(res.err_msg, {icon: 5});
}
});
form.on('submit(save_supplier_share_apply)', function (data) {
let url = '/api/supplier_share_apply/SaveSupplierShareApply';
let res = ajax(url, data.field);
if (!res) {
layer.msg('网络错误,请重试', {icon: 6});
} else {
if (res.err_code === 0) {
admin.closeThisDialog();
parent.layer.msg(res.err_msg, {icon: 6});
} else {
parent.layer.msg(res.err_msg, {icon: 5});
}
}
return false;
});
form.on('submit(cancel)', function (data) {
admin.closeThisDialog();
});
});
</script>