lists.js 5.6 KB

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