lists.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. //public\assets\json\area.js
  2. //import {area } from "./json/area.js"
  3. define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'area','vue', 'ELEMENT'], function ($, undefined, Backend, Table, Form, Area, Vue, ELEMENT) {
  4. ELEMENT.install(Vue)
  5. Vue.use(ELEMENT)
  6. var Controller = {
  7. index: function () {
  8. // 初始化表格参数配置
  9. Table.api.init({
  10. extend: {
  11. index_url: 'product/lists/index' + location.search,
  12. add_url: 'product/lists/add',
  13. edit_url: 'product/lists/edit',
  14. del_url: 'product/lists/del',
  15. multi_url: 'product/lists/multi',
  16. import_url: 'product/lists/import',
  17. dragsort_url: "",
  18. table: 'product_list',
  19. }
  20. });
  21. var table = $("#table");
  22. // 初始化表格
  23. table.bootstrapTable({
  24. url: $.fn.bootstrapTable.defaults.extend.index_url,
  25. pk: 'id',
  26. sortName: 'weigh',
  27. fixedColumns: true,
  28. fixedRightNumber: 1,
  29. columns: [
  30. [
  31. {checkbox: true},
  32. {field: 'id', title: __('Id')},
  33. {field: 'products.zh_title', title: __('Type_id'), operate: false},
  34. {field: 'zh_name', title: __('Zh_name'), operate: false,
  35. formatter : function(value, row, index, field){
  36. return "<span style='display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' title='" + row.zh_name + "'>" + value + "</span>";
  37. },
  38. cellStyle : function(value, row, index, field){
  39. return {
  40. css: {
  41. "white-space": "nowrap",
  42. "text-overflow": "ellipsis",
  43. "overflow": "hidden",
  44. "max-width":"200px"
  45. }
  46. };
  47. }
  48. },
  49. {field: 'en_name', title: __('En_name'), operate: false,
  50. formatter : function(value, row, index, field){
  51. return "<span style='display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' title='" + row.en_name + "'>" + value + "</span>";
  52. },
  53. cellStyle : function(value, row, index, field){
  54. return {
  55. css: {
  56. "white-space": "nowrap",
  57. "text-overflow": "ellipsis",
  58. "overflow": "hidden",
  59. "max-width":"200px"
  60. }
  61. };
  62. }
  63. },
  64. {field: 'thum', title: __('Thum'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
  65. {field: 'weigh', title: __('Weigh'), operate: false},
  66. {field: 'status', title: __('Status'), searchList: {"1":__('上架'),"0":__('下架')}, formatter: Table.api.formatter.toggle},
  67. {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  68. {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  69. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  70. ]
  71. ]
  72. });
  73. // 为表格绑定事件
  74. Table.api.bindevent(table);
  75. // 修改添加窗口的大小
  76. $(".btn-add").data("area", ["60%", "80%"]);
  77. table.on('post-body.bs.table',function () {
  78. $('.btn-editone').data("area",["80%","100%"]);
  79. });
  80. },
  81. add: function () {
  82. Controller.api.bindevent();
  83. },
  84. edit: function () {
  85. Controller.api.bindevent();
  86. },
  87. api: {
  88. bindevent: function () {
  89. Form.api.bindevent($("form[role=form]"));
  90. let dataCode = [];
  91. if((Config.areaCode).length > 0) dataCode = JSON.parse(Config.areaCode);
  92. new Vue({
  93. el: '#app',
  94. data() {
  95. return {
  96. data: dataCode,
  97. props: { multiple: true },
  98. options:area
  99. };
  100. },
  101. methods:{
  102. handleChange(e){
  103. let txt = this.$refs.ca.getCheckedNodes(),txtArr = Array();
  104. txt.forEach(vv => {
  105. txtArr.push($.makeArray((vv.pathLabels).join('-')) );
  106. });
  107. $('#c-product_area').val(JSON.stringify(this.data))
  108. $('#c-product_area_txt').val(JSON.stringify(txtArr))
  109. }}
  110. })
  111. },
  112. }
  113. };
  114. return Controller;
  115. });