InvoiceCreate.cshtml 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. @using System.Web.UI.HtmlControls
  2. @using Abp.Timing
  3. @using ShwasherSys.Authorization.Permissions
  4. @using ShwasherSys.Models.Layout
  5. @using ShwasherSys.Models.Modal
  6. @{
  7. /**/
  8. ViewBag.ActiveMenu = PermissionNames.PagesInvoiceInfoInvoiceCreate; //The menu item will be active for this page.
  9. ViewBag.Title = "客户发票生成";
  10. string initStickNum = "S"+Clock.Now.ToString("yyMMdd -HHmmss");
  11. string stickMan = ViewBag.InitStickMan;
  12. /*var searchForm = new SearchFormViewModal(new List<SearchItem>()
  13. {
  14. new SearchItem("id", "发货单号"),
  15. new SearchItem("sendDate", "发货日期",FiledType.Dnull,ExpType.Greater),
  16. new SearchItem("sendDate", "到",FiledType.Dnull,ExpType.LessOrEqual),
  17. new SearchItem("customerId", "客户编号").SetSearchIcon("query_customer_modal"),
  18. new SearchItem("stockNo", "客户订单号"),
  19. new SearchItem("isbill", "开票状态").SetSearchItem(stickBillStatusList)
  20. }, false);*/
  21. }
  22. @section css{
  23. <link href="~/Content/Plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" rel="stylesheet" />
  24. <style>
  25. .form-box {
  26. min-height: 50px;
  27. }
  28. .form-box .input-group-addon {
  29. background: #d1dcf9;
  30. border-color: #d1dcf9;
  31. color: #563d7c;
  32. }
  33. .form-box .form-control {
  34. border-color: #d1dcf9;
  35. }
  36. .form-box .form-box-column {
  37. float: left;
  38. min-width: 250px;
  39. width: 18%;
  40. margin: 0 5px;
  41. }
  42. .btn-action {
  43. margin-left: 20px;
  44. width: 100px;
  45. margin-top: 0px;
  46. }
  47. .table-box .btn-toolbar {
  48. background: #E6E6FA;
  49. border: 1px solid #E6E6FA;
  50. }
  51. .lable-value {
  52. padding: .4rem .25rem;
  53. }
  54. .KeyWords {
  55. border-radius: 0 0 0 0 !important;
  56. }
  57. </style>
  58. }
  59. <div class="row" style="margin: 0 0;">
  60. <div class="col-xs-12" style="padding: 0 5px;">
  61. <div class="nav-tabs-custom" style="margin-bottom: 5px;">
  62. <ul class="nav nav-tabs">
  63. <li class="active"><a href="#query_tab" data-toggle="tab">查询信息页</a></li>
  64. <li><a href="#createInvoice_tab" data-toggle="tab">填开发票页</a></li>
  65. </ul>
  66. <div class="tab-content form-box">
  67. <div class="tab-pane active" id="query_tab" style="width: 100%;">
  68. <div class="form-box-column">
  69. <div class="form-group-sm input-group">
  70. <div class="input-group-addon" style="">
  71. <span>客户编号</span>
  72. </div>
  73. <input type="text" class="form-control KeyWords" style="border-radius: 0 0 0 0 !important;" id="customerId" name="customerId" data-keyField="customerId" data-fieldType="0" data-expType="0" readonly="readonly" />
  74. <div class="input-group-addon" style="cursor: pointer;" onclick="ShowQueryModal('query_customer_modal')">
  75. <i class="iconfont icon-search"></i>
  76. </div>
  77. </div>
  78. </div>
  79. <div class="form-box-column">
  80. <div class="form-group-sm input-group">
  81. <div class="input-group-addon">
  82. <span>日期</span>
  83. </div>
  84. <input type="text" class="form-control KeyWords" id="startDate" style="border-radius: 0 0 0 0 !important;" name="startDate" data-keyField="creationTime" data-fieldType="5" data-expType="2" />@*//data-keyField="sendDate" data-fieldType="6"*@
  85. <div class="input-group-addon" style="cursor: pointer;" onclick="BtnSearch()">
  86. <i class="iconfont icon-search"></i>
  87. </div>
  88. </div>
  89. </div>
  90. <div class="form-box-column">
  91. <div class="form-group-sm input-group">
  92. <div class="input-group-addon">
  93. <span>至</span>
  94. </div>
  95. <input type="text" class="form-control KeyWords" id="endDate" name="endDate" style="border-radius: 0 0 0 0 !important;" data-keyField="creationTime" data-fieldType="5" data-expType="5" />@*//data-keyField="sendDate" data-fieldType="6"*@
  96. <div class="input-group-addon" style="cursor: pointer;" onclick="BtnSearch()">
  97. <i class="iconfont icon-search"></i>
  98. </div>
  99. </div>
  100. </div>
  101. </div>
  102. <div class="tab-pane" id="createInvoice_tab" style="width: 100%; height: 70px;">
  103. <div style="width: 100%; height: 30px;">
  104. <form id="formInvoice">
  105. <div class="form-box-column">
  106. <div class="form-group-sm input-group">
  107. <div class="input-group-addon" style="">
  108. <span>发票号</span>
  109. </div>
  110. <input type="text" class="form-control" id="stickNum" name="stickNum" value="@initStickNum" />
  111. </div>
  112. </div>
  113. <div class="form-box-column">
  114. <div class="form-group-sm input-group">
  115. <div class="input-group-addon">
  116. <span>开票日期</span>
  117. </div>
  118. <input type="text" class="form-control" id="creatDate" name="creatDate" />
  119. </div>
  120. </div>
  121. <div class="form-box-column">
  122. <div class="form-group-sm input-group">
  123. <div class="input-group-addon">
  124. <span>开票人</span>
  125. </div>
  126. <input type="text" class="form-control" id="stickMan" name="stickMan" value="@stickMan" />
  127. </div>
  128. </div>
  129. <div class="form-box-column">
  130. <div class="form-group-sm input-group">
  131. <div class="input-group-addon">
  132. <span>备注</span>
  133. </div>
  134. <input type="text" class="form-control" id="description" name="description" />
  135. </div>
  136. </div>
  137. </form>
  138. </div>
  139. <div style="margin-top: 5px; height: 35px;">
  140. <div class="form-box-column">
  141. <button type="button" class="btn btn-block btn-info btn-sm" id="createStickBillBtn" style="width: 360px;" onclick="CreateStickBill()"><i class="iconfont icon-fapiao"></i><span style="font-size: 1.3rem;"><strong>开发票</strong></span>&nbsp;&nbsp;<span style="color: red;">(发票号为你真实的发票编号应该是唯一不重复的)</span></button>
  142. </div>
  143. </div>
  144. </div>
  145. </div>
  146. </div>
  147. </div>
  148. </div>
  149. <div class="table-box mr-4 iwb-bootstrap-table">
  150. <div class="btn-toolbar row" id="tableTool" style="display: none;" role="toolbar" aria-label="Toolbar with button groups">
  151. <div class="col-sm-12 col-lg-12 pull-left" style="padding: 0">
  152. <form class="form-horizontal" style="padding: 0 10px" id="form">
  153. <div class="form-group-sm row">
  154. <label class="iwb-label col-md-1 control-label" for="customerName">客户:</label>
  155. <div class="col-md-2">
  156. <label class="lable-value" id="customerName"></label>
  157. </div>
  158. <label class="iwb-label col-md-1 control-label " for="address">地址:</label>
  159. <div class="col-md-2" style="padding: 0 5px">
  160. <label class="lable-value" id="address"></label>
  161. </div>
  162. <label class="iwb-label col-md-1 control-label " for="telephone">联系电话:</label>
  163. <div class="col-md-2">
  164. <label class="lable-value" id="telephone"></label>
  165. </div>
  166. <label class="iwb-label col-md-1 control-label " for="linkMan">联系人:</label>
  167. <div class="col-md-2" style="padding: 0 5px">
  168. <label class="lable-value" id="linkMan"></label>
  169. </div>
  170. </div>
  171. @*<div class="form-group-sm row">
  172. </div>*@
  173. </form>
  174. </div>
  175. </div>
  176. <table id="table"
  177. data-url="/api/services/app/OrderStickBill/GetAllCreateView"
  178. data-striped="true" data-id-field="id" data-unique-id="id"
  179. data-method="post"
  180. data-side-pagination="server"
  181. data-content-type="application/x-www-form-urlencoded; charset=UTF-8"
  182. data-cache="false"
  183. data-pagination="false" 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"
  184. data-query-params="QueryParams"
  185. data-response-handler="ResponseHandlerNoPage"
  186. data-click-to-select="true"
  187. data-single-select="false">
  188. <thead>
  189. <tr class="row">
  190. <th data-field="state" data-checkbox="true"></th>
  191. @*<th data-align="center" data-field="stockNo">客户订单号</th>
  192. <th data-align="center" data-field="orderSendBillNo">发货单号</th>
  193. <th data-align="center" data-field="statementBillNo">对账单号</th>
  194. <th data-align="center" data-field="sendDate">发货日期</th>
  195. <th data-align="center" data-field="partNo">零件号</th>
  196. <th data-align="center" data-field="model">规格</th>
  197. <th data-align="center" data-field="remark">描述</th>
  198. <th data-align="center" data-field="surfaceColor">表色</th>
  199. <th data-align="center" data-field="rigidity">硬度</th>
  200. <th data-align="center" data-field="sendQuantity">数量</th>
  201. <th data-align="center" data-field="price">单价</th>
  202. <th data-align="center" data-field="total">金额</th>*@
  203. <th data-align="center" data-field="statementBillNo">对账单号</th>
  204. <th data-align="center" data-field="customerId">客户编码</th>
  205. <th data-align="center" data-field="customerName">客户名称</th>
  206. <th data-align="center" data-field="creationTime">日期</th>
  207. <th data-align="center" data-field="billMan">对账人</th>
  208. <th data-align="center" data-field="description">备注</th>
  209. </tr>
  210. </thead>
  211. </table>
  212. </div>
  213. @section modal
  214. {
  215. <section>
  216. @Html.Partial("Modals/Query/_CustomerEx", new QueryParamModel("customerId","BtnSearch()"))
  217. </section>
  218. }
  219. @section scripts
  220. {
  221. <script src="~/Content/Plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
  222. <script src="~/Content/Plugins/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
  223. <script>
  224. var datePickerOpt = {
  225. language: 'zh-CN',
  226. format: "yyyy-mm-dd",
  227. todayBtn: true,
  228. autoclose: true,
  229. startView: 2,
  230. minView: 2,
  231. maxView: 4
  232. //showSecond: true,
  233. //showHours: true,
  234. //minuteStep: 10
  235. };
  236. $(function () {
  237. $("#formInvoice")[0].reset();
  238. $("#startDate").datetimepicker(datePickerOpt);
  239. $("#endDate").datetimepicker(datePickerOpt);
  240. $("#creatDate").datetimepicker(datePickerOpt);
  241. var nowDate = new Date();
  242. var preDate = new Date(nowDate.getTime() - 30 * 24 * 60 * 60 * 1000);
  243. var endDate = new Date(nowDate.getTime() + 24 * 60 * 60 * 1000);
  244. $("#startDate").val(preDate.Format("yyyy-MM-dd"));
  245. $("#endDate").val(endDate.Format("yyyy-MM-dd"));
  246. $("#creatDate").val(nowDate.Format("yyyy-MM-dd"));
  247. $("#customerId").val("");
  248. LoadTable({
  249. responseHandler:ResponseHandlerNoPage
  250. });
  251. });
  252. function BtnSearch() {
  253. GetSearchList();
  254. ReloadCusotmerInfo();
  255. RefreshTable();
  256. }
  257. function ReloadCusotmerInfo() {
  258. var customerId = $("#customerId").val();
  259. if (!customerId) {
  260. return;
  261. }
  262. SaveAjax({
  263. url: window.appUrl + "Query/GetCustomerInfo",
  264. data: { id: customerId },
  265. isAlert: false,
  266. isValiate: false,
  267. success: function(res) {
  268. if (res) {
  269. $("#customerName").html(res.customerName);
  270. $("#address").html(res.address);
  271. $("#telephone").html(res.telephone);
  272. $("#linkMan").html(res.linkMan);
  273. $("#tableTool").show();
  274. } else {
  275. $("#tableTool").hide();
  276. }
  277. }
  278. });
  279. }
  280. function CreateStickBill() {
  281. var rows = $("#table").bootstrapTable("getSelections");
  282. if (rows.length > 0) {
  283. var orderSendIds = "";
  284. rows.forEach(function(r) {
  285. orderSendIds += "," + r.id;
  286. });
  287. if (orderSendIds) {
  288. orderSendIds = orderSendIds.substr(1);
  289. }
  290. var stickNum = $("#stickNum").val();
  291. var data = { CustomerId:$("#customerId").val(),OrderSendIds: orderSendIds ,Id:stickNum};
  292. $.extend(data, formUtil.Serialize($("#formInvoice")));
  293. SaveAjax({
  294. url: window.appUrl + "OrderStickBill/Create",
  295. data: data,
  296. dataType: "json",
  297. isValiate: false,
  298. isAlert: false,
  299. success: function(res) {
  300. if (res) {
  301. BtnSearch();
  302. abp.message.success("发票创建成功!").done(function() {
  303. window.open("@Url.Action("InvoiceDetail")/" + stickNum, "_blank");
  304. });
  305. }
  306. }
  307. });
  308. } else
  309. abp.message.warn(abp.localization.localize("ChooseOneToOp"));
  310. }
  311. function GetSearchList() {
  312. var searchList = $("#query_tab").find(".KeyWords");
  313. window._searchList = [];
  314. //_searchList.push({
  315. // KeyWords: "1",
  316. // KeyField: "statementState",
  317. // FieldType: 2,
  318. // ExpType: 1
  319. //});
  320. searchList.each(function(i, v) {
  321. var keyWords = $(v).val();
  322. var keyField = $(v).data("keyfield");
  323. var fieldType = $(v).data("fieldtype");
  324. var expType = $(v).data("exptype");
  325. if (!keyWords && keyField === "customerId") {
  326. keyWords = "N_";
  327. }
  328. if (keyWords) {
  329. if (fieldType === 6 && expType === 5) {
  330. var endDate = new Date(keyWords);
  331. var qDate = new Date(endDate.getTime() + 24 * 60 * 60 * 1000);
  332. keyWords = qDate.Format("yyyy-MM-dd");
  333. }
  334. _searchList.push({
  335. KeyWords: keyWords,
  336. KeyField: keyField,
  337. FieldType: fieldType,
  338. ExpType: expType
  339. });
  340. }
  341. });
  342. }
  343. function OnAll() {
  344. $("#createStickBillBtn").prop('disabled', config.table.bootstrapTable('getSelections').length === 0);
  345. }
  346. function OnLoadSuccess() {
  347. $(".bs-checkbox").find("input").addClass("filled-in").after("<label></label");
  348. $("#table thead th.bs-checkbox ").off("click.checkOnTable").on("click.checkOnTable",
  349. function() {
  350. $(this).find("input").click();
  351. });
  352. abp.ui.clearBusy();
  353. }
  354. </script>
  355. <script>
  356. function KeepClock() {
  357. SaveAjax({
  358. url: window.appUrl + "Common/KeepClock",
  359. async:false,
  360. isValidate: false,
  361. isAlert: false,
  362. success: function(res) {
  363. console.log('页面与服务器交户:'+res);
  364. }
  365. });
  366. setTimeout(KeepClock, 3 * 60 * 1000);
  367. }
  368. setTimeout(KeepClock, 3 * 60 * 1000);
  369. // 对Date的扩展,将 Date 转化为指定格式的String
  370. // 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符,
  371. // 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字)
  372. // 例子:
  373. // (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423
  374. // (new Date()).Format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18
  375. Date.prototype.Format = function(fmt) { //author: meizz
  376. var o = {
  377. "M+": this.getMonth() + 1, //月份
  378. "d+": this.getDate(), //日
  379. "h+": this.getHours(), //小时
  380. "m+": this.getMinutes(), //分
  381. "s+": this.getSeconds(), //秒
  382. "q+": Math.floor((this.getMonth() + 3) / 3), //季度
  383. "S": this.getMilliseconds() //毫秒
  384. };
  385. if (/(y+)/.test(fmt))
  386. fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  387. for (var k in o)
  388. if (new RegExp("(" + k + ")").test(fmt))
  389. fmt = fmt.replace(RegExp.$1,
  390. (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  391. return fmt;
  392. }
  393. //将数字转换成金额显示 n是小数点后位数
  394. function toNumber(num, n) {
  395. var re = String(num);
  396. var dotfront = "";
  397. var dotlast = "";
  398. if (re.indexof('.') > -1) {
  399. var sarr = re.spilt('.');
  400. dotfront = sarr[0];
  401. dotlast = sarr[1];
  402. var dotlastlength = strlen(dotlast);
  403. if (dotlastlength < n) {
  404. for (var j = 0; j < n - dotlastlength; j++) {
  405. dotlast += "0";
  406. }
  407. }
  408. if (dotlastlength > n) {
  409. dotlast = dotlast.substr(0, n);
  410. }
  411. } else {
  412. dotfront = re;
  413. for (var i = 0; i < n; i++) {
  414. dotlast += "0";
  415. }
  416. }
  417. num = dotfront + '.' + dotlast;
  418. return num;
  419. }
  420. function _formatAmount(strData, n) {
  421. var CurrencyAndAmountRegExp =
  422. /^(\d{1,18})|(\d{1,18}\.)|(\d{1,17}\.\d{0,1})|(\d{1,16}\.\d{0,2})|(\.\d{1,2})$/;
  423. var _result = CurrencyAndAmountRegExp.test(strData);
  424. if (_result == false) {
  425. return strData;
  426. } // 一般来说最多就6位吧,当然如果有特殊需求可自行更改(`・∀・´)
  427. n = n > 0 && n <= 6 ? n : 2;
  428. var formatData = parseFloat((strData + '').replace(/[^\d\.-]/g, '')).toFixed(n) + '';
  429. var l = formatData.split('.')[0].split('').reverse();
  430. var r = formatData.split('.')[1];
  431. var t = '';
  432. for (i = 0; i < l.length; i++) {
  433. t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? ',' : '');
  434. }
  435. return t.split('').reverse().join('') + '.' + r;
  436. }
  437. function strlen(str) {
  438. var len = 0;
  439. for (var i = 0; i < str.length; i++) {
  440. var c = str.charCodeAt(i);
  441. //单字节加1
  442. if ((c >= 0x0001 && c <= 0x007e) || (0xff60 <= c && c <= 0xff9f)) {
  443. len++;
  444. } else {
  445. len += 2;
  446. }
  447. }
  448. return len;
  449. }
  450. </script>
  451. }