| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- @using ContractService.Configuration
- @using ContractService.Authorization
- @using ContractService.Views.Shared.Modals
- @using ContractService.Views.Shared.SearchForm
- @using ContractService.Views.Shared.Table
- @{
- ViewBag.Title = "企业员工信息维护";
- string activeMenu = PermissionNames.PagesClientMgStaffMg; //The menu item will be active for this page.
- ViewBag.ActiveMenu = activeMenu;
- string companyNo = ViewBag.CompanyNo ?? "";
- var searchForm = new SearchFormViewModel(new List<SearchItem>()
- {
- new SearchItem("code","员工编号"),
- new SearchItem("name","员工姓名"),
- new SearchItem("email", "电子邮箱"),
- new SearchItem("birthday","出生日期",FieldType.Dn),
- new SearchItem("phoneNumber","联系号码"),
- }, "search-form", false);
- var table = new TableViewModel(IwbConsts.ApiAppUrl + "ClientStaff/GetAll", activeMenu, searchForm)
- .SetFields(new List<FieldItem>()
- {
- new FieldItem("code", "员工编号"),
- new FieldItem("name", "员工姓名"),
- //new FieldItem("profile", "员工描述"),
- new FieldItem("userName", "绑定账号","UserNameFormatter"),
- new FieldItem("birthday", "出生日期", "DateFormatter"),
- new FieldItem("idCard", "身份证号"),
- new FieldItem("phoneNumber", "联系号码"),
- new FieldItem("phoneNumber2", "备用号码"),
- });
- if (AbpSession.AccountType == AccountTypeDefinition.System)
- {
- table.AddField(new FieldItem("companyName", "公司信息"));
- table.AddField(new FieldItem("organizationName", "公司部门"));
- table.AddField(new FieldItem("isMaster", "是否负责人","IsMasterFormatter"));
- }
- else
- {
- table.AddField(new FieldItem("organizationName", "公司部门"));
- }
- var inputs = new List<Input>()
- {
- new InputHide("id"),
- new Input("code", "员工编号"),
- new Input("name", "员工姓名"),
- new Input("email", "电子邮箱"),
- new Input("organizationNo", "员工部门").SetSelectOptions(""),
- new Input("phoneNumber", "联系号码"),
- new InputDate("birthday", "出生日期").SetNotRequired(),
- new Input("idCard", "身份证号").SetNotRequired(),
- new Input("phoneNumber2", "备用号码").SetNotRequired(),
- new InputTextarea("profile", "员工描述").SetNotRequired(),
- };
- var modalBody = new ModalBodyViewModel().AddInputs(inputs);
- var modal = new ModalViewModel("员工").SetBody(modalBody);
- var modal_bind = new ModalViewModel("绑定账号", "", new ModalBodyViewModel(new List<Input>()
- {
- new InputHide("staffNo"),
- new Input("userName", "用户账号").SetSelectOptions("")
- }, "form-bind"), "modal-bind");
- }
- @section css{
- }
- @Html.Partial("Table/_Table", table)
- @section modal{
- <!--Modal Start-->
- @Html.Partial("Modals/_Modal", modal)
- @Html.Partial("Modals/_Modal", modal_bind)
- <!--Modal End-->
- }
- @section scripts
- {
- <script type="text/javascript">
- var $table;
- $(function() {
- @if (string.IsNullOrEmpty(companyNo))
- {
- <text>
- $table = LoadTable();
- </text>
- }
- else
- {
- <text>
- $table = LoadTable({
- searchList: [{ "KeyField": "company", "KeyWords": '@(companyNo)', "FieldType": 0, "ExpType": 0 }]
- });
- </text>
- }
- var funs = window.iwbfuns || { none: function() { console.log("No type"); } };
- funs["btnCreate"] = function() {
- if ('@(companyNo)') {
- $.iwbAjax4({
- url: abp.appUrl + "Query/GetOrgSelectTreeStr?no=@companyNo&type=1",
- success: function(res) {
- $("#organizationNo").html(res);
- BtnCreate({ data: { id: "" }, select2tree:"organizationNo" });
- }
- });
- } else {
- abp.message.warn("当前账号不能创建!");
- }
- }
- funs["btnUpdate"] = function() {
- var row = $table.bootstrapTable("getSelections")[0];
- if (row) {
- $.iwbAjax4({
- url: abp.appUrl + "Query/GetOrgSelectTreeStr?type=1&no="+row.companyNo,
- success: function(res) {
- $("#organizationNo").html(res);
- BtnUpdate({ select2tree:"organizationNo" });
- }
- });
- }
- };
- funs["btnBind"] = function(url) {
- var row = $table.bootstrapTable("getSelections")[0];
- if (row) {
- if (row.userName) {
- abp.message.warn("已绑定账号,请勿重复操作!");
- return;
- }
- OpenModal({
- url: url,
- modal: "modal-bind",
- data: { staffNo: row.id },
- table: 'table'
- });
- }
- };
- funs["btnUnBind"] = function(url) {
- var row = $table.bootstrapTable("getSelections")[0];
- if (row) {
- if (!row.userName) {
- abp.message.warn("未绑定账号,请检查后再试!");
- return;
- }
- MsgConfirm("你确定解绑账号吗?(解绑后账号会被锁定,需联系管理员激活!)",
- "解绑账号",
- function() {
- $.iwbAjax1({
- url: url,
- data: { id: row.id },
- success: RefreshTable
- });
- });
- }
- };
- var take = 10;
- $('#modal-bind #userName').select2({
- ajax: {
- url: abp.appUrl + "Query/UnBindUserAcInfos",
- type: "post",
- dataType: 'json',
- delay: 250,
- data: function(params) {
- //console.log(params);
- var page = params.page || 1;
- var queryParam = {
- AccountType: @(AccountTypeDefinition.Client),
- Word: params.term, // search term
- Skip: (page - 1) * take,
- Take: take
- };
- return queryParam;
- },
- processResults: function(data, params) {
- console.log(data, params);
- params.page = params.page || 1;
- var result = {
- results: data.items.map(function(v) {
- v.id = v.valueKey;
- v.text = v.nameKey;
- return v;
- }),
- pagination: {
- more: (params.page * 10) < data.totalCount
- }
- };
- //console.log(data, params);
- return result;
- },
- transport: function(params, success, failure) {
- //console.log("1", params);
- params = params || {};
- params.success = success;
- params.error = failure;
- var $request = $.iwbAjax41(params);
- return $request;
- },
- cache: true
- },
- cache: true,
- minimumInputLength: 0,
- templateResult: function(res) {
- if (res.loading) {
- return res.text;
- }
- return '{0} ({1})'.format(res.text, res.id);
- },
- templateSelection: function(res) {
- return res.text;
- }
- });
- });
- </script>
- <!--格式化-->
- <script id="formatter-script" type="text/javascript">
- function TypeFormatter(v) {
- var name = $('#hid-type option[value="' + v + '"]').text();
- switch (v) {
- case 0:
- return '<span class="label sm label-danger">' + name + '</span>';
- default:
- return '<span class="label sm label-info">' + name + '</span>';
- }
- }
- function UserNameFormatter(v) {
- if (v) {
- return '<span class="label sm label-success">' + v + '</span>';
- } else {
- return '<span class="label sm label-danger">未绑定账号</span>';
- }
- }
- function IsMasterFormatter(v) {
- if (v) {
- return '<span class="label sm label-success">负责人</span>';
- } else {
- return '';
- }
- }
- </script>
- }
- <section style="display: none">
- <select id="hid-type">
- <option value=""></option>
- </select>
- @*@Html.DropDownList("hid-type", type)*@
- </section>
|