InvoiceMg.cshtml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. @using System.Web.UI.HtmlControls
  2. @using ShwasherSys
  3. @using ShwasherSys.Authorization.Permissions
  4. @using ShwasherSys.Models.Layout
  5. @using ShwasherSys.Models.Modal
  6. @using ShwasherSys.Views.Shared.New.Modals
  7. @using InputTypes = ShwasherSys.Models.Modal.InputTypes
  8. @using ModalBodyViewModel = ShwasherSys.Models.Modal.ModalBodyViewModel
  9. @using ModalHeaderViewModel = ShwasherSys.Models.Modal.ModalHeaderViewModel
  10. @{
  11. /**/
  12. ViewBag.ActiveMenu = PermissionNames.PagesInvoiceInfoInvoiceMg; //The menu item will be active for this page.
  13. ViewBag.Title = "客户发票维护";
  14. List<SelectListItem> invoiceState = ViewBag.InvoiceState, invoiceType = new List<SelectListItem>()
  15. {
  16. new SelectListItem(){Text = @"红冲发票--退款",Value = InvoiceTypeDefinition.RedReturn+""},
  17. new SelectListItem(){Text = @"红冲发票--少收",Value = InvoiceTypeDefinition.RedLess+""},
  18. new SelectListItem(){Text = @"红冲发票--多收",Value = InvoiceTypeDefinition.RedOver+""},
  19. },invoiceType2= new List<SelectListItem>(){new SelectListItem(){Text = @"正常发票",Value = InvoiceTypeDefinition.Normal+""}};
  20. invoiceType2.AddRange(invoiceType);
  21. var searchForm = new SearchFormViewModal(new List<SearchItem>()
  22. {
  23. new SearchItem("id", "发票号"),
  24. new SearchItem("creatDate", "开发票日期",FiledType.Dnull,ExpType.GreaterOrEqual),
  25. new SearchItem("creatDate", "到",FiledType.Dnull,ExpType.LessOrEqual),
  26. new SearchItem("customerId", "客户编号",expType:ExpType.Contains).SetSearchIcon("query_customer_modal")
  27. }, false);
  28. }
  29. @section css{
  30. <link href="~/Content/Plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" rel="stylesheet" />
  31. }
  32. <div class="table-box mr-4 iwb-bootstrap-table">
  33. @Html.Action("ToolMenu", "Layout", new { pageName = ViewBag.ActiveMenu, searchForm })
  34. <table id="table"
  35. data-url="/api/services/app/OrderStickBill/GetViewAll"
  36. data-striped="true" data-id-field="id" data-unique-id="id"
  37. data-method="post"
  38. data-side-pagination="server"
  39. data-content-type="application/x-www-form-urlencoded; charset=UTF-8"
  40. data-cache="false"
  41. data-pagination="true" data-page-size="30" data-page-number="1" data-page-list="[30,50,100,200]" data-pagination-detail-h-align="right" data-pagination-h-align="left"
  42. data-query-params="QueryParams"
  43. data-response-handler="ResponseHandler"
  44. data-click-to-select="true"
  45. data-single-select="true"
  46. data-show-jumpto="true">
  47. <thead>
  48. <tr class="row" id="header">
  49. <th data-field="state" data-checkbox="true"></th>
  50. <th data-align="center" data-field="stickNum">发票号</th>
  51. <th data-align="center" data-field="customerId">客户编号</th>
  52. <th data-align="center" data-field="customerName">客户名称</th>
  53. <th data-align="center" data-field="creatDate">开票日期</th>
  54. <th data-align="center" data-field="stickMan">开票人</th>
  55. <th data-align="center" data-field="invoiceType" data-formatter="InvoiceTypeFormatter">发票类型</th>
  56. <th data-align="center" data-field="totalPrice">金额(含税)</th>
  57. <th data-align="center" data-field="afterTaxTotalPrice">金额(不含税)</th>
  58. <th data-align="center" data-field="amount" data-formatter="AmountFormatter">确认金额</th>
  59. <th data-align="center" data-field="invoiceState" data-formatter="InvoiceStateFormatter">是否收款</th>
  60. <th data-align="center" data-field="currencyId">货币</th>
  61. <th data-align="center" data-field="description">备注</th>
  62. </tr>
  63. </thead>
  64. </table>
  65. </div>
  66. @section modal
  67. {
  68. <section>
  69. <div class="modal fade" id="modal_red" role="dialog" tabindex="-1" aria-labelledby="ModalLabel" aria-hidden="true">
  70. <div class="modal-dialog modal-dialog-centered" role="document" style="width: 600px">
  71. <div class="modal-content">
  72. @Html.Partial("Modals/_ModalHeader", new ModalHeaderViewModel("红冲发票"))
  73. @{
  74. var inputs3 = new List<InputViewModel>
  75. {
  76. new InputViewModel("customerId",hide:true),
  77. //new InputViewModel("id",hide:true),
  78. new InputViewModel("id",displayName:"新发票号"),
  79. new InputViewModel("originalStickNum",displayName:"原发票号").SetSearchIcon("query_invoice_modal","modal_red"),
  80. new InputViewModel("customerName",displayName:"客户名称"),
  81. new InputViewModel("stickMan",displayName:"开票人").SetNotRequired(),
  82. new InputViewModel("creatDate",displayName:"开票日期",@class:"iwb-date"),
  83. new InputViewModel("invoiceType",InputTypes.List,"发票类型",other:"onchange=InvoiceTypeChange()").SetSelectOptions(invoiceType),
  84. new InputViewModel("orderNo",displayName:"订单明细号").SetNotRequired(),
  85. new InputViewModel("returnOrderNo",displayName:"退货单号",@class:"type1"),
  86. new InputViewModel("amount",displayName:"实际金额",@class:"number",other:"min=0.001"),
  87. new InputViewModel("description",InputTypes.Textarea,displayName:"发票详情").SetNotRequired(),
  88. };
  89. //var specials = new List<SpecialInputModel>();
  90. }
  91. @Html.Partial("Modals/_ModalBody", new ModalBodyViewModel(inputs3))
  92. @Html.Partial("Modals/_ModalFooter", "0")
  93. </div>
  94. </div>
  95. </div>
  96. </section>
  97. <section>
  98. <div class="modal fade" id="modal" role="dialog" tabindex="-1" aria-labelledby="ModalLabel" aria-hidden="true">
  99. <div class="modal-dialog modal-dialog-centered" role="document" style="width: 600px">
  100. <div class="modal-content">
  101. @Html.Partial("Modals/_ModalHeader", new ModalHeaderViewModel("发票号"))
  102. @{
  103. var inputs = new List<InputViewModel>
  104. {
  105. new InputViewModel("id",hide:true),
  106. new InputViewModel("stickNum",displayName:"新发票号"),
  107. //new InputViewModel("invoiceState",InputTypes.List,displayName:"是否收款").SetSelectOptions(invoiceState),
  108. //new InputViewModel("amount",displayName:"实际收款金额",@class:"number").SetNotRequired(),
  109. new InputViewModel("customerId",hide:true),
  110. };
  111. //var specials = new List<SpecialInputModel>();
  112. }
  113. @Html.Partial("Modals/_ModalBody", new ModalBodyViewModel(inputs))
  114. @Html.Partial("Modals/_ModalFooter", "0")
  115. </div>
  116. </div>
  117. </div>
  118. </section>
  119. <section>
  120. <div class="modal fade" id="modal2" role="dialog" tabindex="-1" aria-labelledby="ModalLabel" aria-hidden="true">
  121. <div class="modal-dialog modal-dialog-centered" role="document" style="width: 600px">
  122. <div class="modal-content">
  123. @Html.Partial("Modals/_ModalHeader", new ModalHeaderViewModel("发票号"))
  124. @{
  125. var inputs2 = new List<InputViewModel>
  126. {
  127. new InputViewModel("id",hide:true),
  128. new InputViewModel("invoiceState",InputTypes.List,displayName:"是否收款").SetSelectOptions(invoiceState),
  129. new InputViewModel("amount",displayName:"实际收(退)金额",@class:"number",other:"min=0.001").SetNotRequired(),
  130. new InputViewModel("customerId",hide:true),
  131. };
  132. //var specials = new List<SpecialInputModel>();
  133. }
  134. @Html.Partial("Modals/_ModalBody", new ModalBodyViewModel(inputs2))
  135. @Html.Partial("Modals/_ModalFooter", "0")
  136. </div>
  137. </div>
  138. </div>
  139. </section>
  140. <section>
  141. @Html.Partial("Modals/Query/_Invoice", "originalStickNum,customerId,customerName,amount")
  142. @Html.Partial("Modals/Query/_Customer", "customerId|KeyWords-4,customerName")
  143. </section>
  144. @*@Html.Partial("Modals/Query/_Employee", "handleUser,handleUserName")*@
  145. }
  146. @section scripts
  147. {
  148. <script src="~/Content/Plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
  149. <script src="~/Content/Plugins/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
  150. <script>
  151. var datePickerOpt = {
  152. language: 'zh-CN',
  153. format: "yyyy-mm-dd",
  154. todayBtn: true,
  155. autoclose: true,
  156. startView: 2,
  157. minView: 2,
  158. maxView: 4
  159. //showSecond: true,
  160. //showHours: true,
  161. //minuteStep: 10
  162. };
  163. $(function() {
  164. //$("#KeyWords-2").datetimepicker(datePickerOpt);
  165. //$("#KeyWords-3").datetimepicker(datePickerOpt);
  166. var nowDate = new Date();
  167. var preDate = new Date(nowDate.getTime() - 30 * 24 * 60 * 60 * 1000);
  168. $("#KeyWords-2").val(preDate.Format("yyyy-MM-dd"));
  169. $("#KeyWords-3").val(nowDate.Format("yyyy-MM-dd"));
  170. LoadTable();
  171. funs["btnDelete"] = function(url) {
  172. BtnDelete(url);
  173. }
  174. /*$.extend(funs, { btnShow: function(url) {
  175. BtnShow(url);
  176. }
  177. });*/
  178. funs["btnCreateRed"] = function (url) {
  179. BtnCreate(url,
  180. {
  181. disabled:"originalStickNum,customerName",
  182. data: {invoiceType:1},
  183. modal: $("#modal_red")
  184. });
  185. }
  186. funs["btnUpdate"] = function (url) {
  187. BtnUpdate(url);
  188. }
  189. funs["btnShow"] = function(url) {
  190. BtnShow(url);
  191. }
  192. funs["btnExportInvoices"] = function(url) {
  193. GetSearchList();
  194. $.iwbAjax4({
  195. url: url,
  196. data:{
  197. MaxResultCount: 1,
  198. SkipCount: 1,
  199. Sorting: '', //排序列名
  200. sortOrder: '', //排位命令(desc,asc)
  201. SearchList: _searchList
  202. },
  203. success: function(res) {
  204. window.location.href = res;
  205. }
  206. });
  207. }
  208. funs["btnUpdateState"] = function (url) {
  209. var rows = $("#table").bootstrapTable("getSelections");
  210. if (rows.length === 1) {
  211. var data = rows[0];
  212. if (data.invoiceType== @(InvoiceTypeDefinition.RedOver) || data.invoiceType=== @(InvoiceTypeDefinition.RedReturn)) {
  213. data.amount = data.amount < 0 ? 0 - data.amount : data.amount;
  214. }
  215. OpenModal(url, { modal: $("#modal2"),modaltitle:"修改发票状态金额",data:data });
  216. } else
  217. abp.message.warn(abp.localization.localize("ChooseOneToOp"));
  218. }
  219. });
  220. function BtnShow(url) {
  221. var rows = config.table.bootstrapTable("getSelections");
  222. if (rows.length === 1) {
  223. let r = rows[0];
  224. if (r.invoiceType !== 0) {
  225. abp.message.warn("非正常发票,不可查看详情!");
  226. return;
  227. }
  228. window.open("@Url.Action("InvoiceDetail")/" + rows[0].id, "_blank");
  229. } else
  230. abp.message.warn(abp.localization.localize("ChooseOneToOp"));
  231. }
  232. function BtnDelete(url) {
  233. var rows = config.table.bootstrapTable("getSelections");
  234. if (rows.length === 1) {
  235. abp.message.confirm("确认撤销此发票?", "撤销发票",function() {
  236. SaveAjax({ url: url, data: { Id: rows[0].id}, isValidate: false });
  237. });
  238. } else
  239. abp.message.warn(abp.localization.localize("ChooseOneToOp"));
  240. }
  241. function InvoiceTypeChange() {
  242. if ($("#invoiceType").val() === "1") {
  243. $('.type1').addClass('required').closest('.form-group-sm').show();
  244. } else {
  245. $('.type1').removeClass('required').closest('.form-group-sm').hide();
  246. }
  247. }
  248. </script>
  249. <script>
  250. function KeepClock() {
  251. SaveAjax({
  252. url: window.appUrl + "Common/KeepClock",
  253. async:false,
  254. isValidate: false,
  255. isAlert: false,
  256. success: function(res) {
  257. console.log('页面与服务器交户:'+res);
  258. }
  259. });
  260. setTimeout(KeepClock, 3 * 60 * 1000);
  261. }
  262. setTimeout(KeepClock, 3 * 60 * 1000);
  263. // 对Date的扩展,将 Date 转化为指定格式的String
  264. // 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符,
  265. // 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字)
  266. // 例子:
  267. // (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423
  268. // (new Date()).Format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18
  269. Date.prototype.Format = function (fmt) { //author: meizz
  270. var o = {
  271. "M+": this.getMonth() + 1, //月份
  272. "d+": this.getDate(), //日
  273. "h+": this.getHours(), //小时
  274. "m+": this.getMinutes(), //分
  275. "s+": this.getSeconds(), //秒
  276. "q+": Math.floor((this.getMonth() + 3) / 3), //季度
  277. "S": this.getMilliseconds() //毫秒
  278. };
  279. if (/(y+)/.test(fmt))
  280. fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  281. for (var k in o)
  282. if (new RegExp("(" + k + ")").test(fmt))
  283. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  284. return fmt;
  285. }
  286. //将数字转换成金额显示 n是小数点后位数
  287. function toNumber(num, n) {
  288. var re = String(num);
  289. var dotfront = "";
  290. var dotlast = "";
  291. if (re.indexof('.') > -1) {
  292. var sarr = re.spilt('.');
  293. dotfront = sarr[0];
  294. dotlast = sarr[1];
  295. var dotlastlength = strlen(dotlast);
  296. if (dotlastlength < n) {
  297. for (var j = 0; j < n - dotlastlength; j++) {
  298. dotlast += "0";
  299. }
  300. }
  301. if (dotlastlength > n) {
  302. dotlast = dotlast.substr(0, n);
  303. }
  304. } else {
  305. dotfront = re;
  306. for (var i = 0; i < n; i++) {
  307. dotlast += "0";
  308. }
  309. }
  310. num = dotfront + '.' + dotlast;
  311. return num;
  312. }
  313. function _formatAmount(strData, n) {
  314. var CurrencyAndAmountRegExp = /^(\d{1,18})|(\d{1,18}\.)|(\d{1,17}\.\d{0,1})|(\d{1,16}\.\d{0,2})|(\.\d{1,2})$/;
  315. var _result = CurrencyAndAmountRegExp.test(strData);
  316. if (_result == false) {
  317. return strData;
  318. } // 一般来说最多就6位吧,当然如果有特殊需求可自行更改(`・∀・´)
  319. n = n > 0 && n <= 6 ? n : 2;
  320. var formatData = parseFloat((strData + '').replace(/[^\d\.-]/g, '')).toFixed(n) + '';
  321. var l = formatData.split('.')[0].split('').reverse();
  322. var r = formatData.split('.')[1];
  323. var t = '';
  324. for (i = 0; i < l.length; i++) {
  325. t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? ',' : '');
  326. }
  327. return t.split('').reverse().join('') + '.' + r;
  328. }
  329. function strlen(str) {
  330. var len = 0;
  331. for (var i = 0; i < str.length; i++) {
  332. var c = str.charCodeAt(i);
  333. //单字节加1
  334. if ((c >= 0x0001 && c <= 0x007e) || (0xff60 <= c && c <= 0xff9f)) {
  335. len++;
  336. }
  337. else {
  338. len += 2;
  339. }
  340. }
  341. return len;
  342. }
  343. </script>
  344. <script id="formatter" type="text/javascript">
  345. function InvoiceStateFormatter(v) {
  346. var name = $('#hid-invoiceState option[value="' + v + '"]').text();
  347. if (v === 1) {
  348. return '<span class="label label-success">' + name + '</span>';
  349. } else {
  350. return '<span class="label label-danger">' + name + '</span>';
  351. }
  352. }
  353. function InvoiceTypeFormatter(v) {
  354. var name = $('#hid-invoiceType option[value="' + v + '"]').text();
  355. switch (v) {
  356. case 1:
  357. return '<span class="label label-danger">' + name + '</span>';
  358. case 2:
  359. return '<span class="label label-success">' + name + '</span>';
  360. case 3:
  361. return '<span class="label label-warning">' + name + '</span>';
  362. default:
  363. return '<span class="label label-info">' + name + '</span>';
  364. }
  365. }
  366. function AmountFormatter(v,r) {
  367. if (v !== r.totalPrice) {
  368. return '<span class="label label-danger">' + v + '</span>';
  369. }
  370. return v;
  371. }
  372. </script>
  373. }
  374. <section style="display: none">
  375. @Html.DropDownList("hid-invoiceState", invoiceState)
  376. @Html.DropDownList("hid-invoiceType", invoiceType2)
  377. </section>