| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- //public\assets\json\area.js
- //import {area } from "./json/area.js"
- define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'area','vue', 'ELEMENT'], function ($, undefined, Backend, Table, Form, Area, Vue, ELEMENT) {
- ELEMENT.install(Vue)
- Vue.use(ELEMENT)
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'product/lists/index' + location.search,
- add_url: 'product/lists/add',
- edit_url: 'product/lists/edit',
- del_url: 'product/lists/del',
- multi_url: 'product/lists/multi',
- import_url: 'product/lists/import',
- dragsort_url: "",
- table: 'product_list',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'weigh',
- fixedColumns: true,
- fixedRightNumber: 1,
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id')},
- {field: 'products.zh_title', title: __('Type_id'), operate: false},
- {field: 'zh_name', title: __('Zh_name'), operate: false,
- formatter : function(value, row, index, field){
- return "<span style='display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' title='" + row.zh_name + "'>" + value + "</span>";
- },
- cellStyle : function(value, row, index, field){
- return {
- css: {
- "white-space": "nowrap",
- "text-overflow": "ellipsis",
- "overflow": "hidden",
- "max-width":"200px"
- }
- };
- }
- },
- {field: 'en_name', title: __('En_name'), operate: false,
- formatter : function(value, row, index, field){
- return "<span style='display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' title='" + row.en_name + "'>" + value + "</span>";
- },
- cellStyle : function(value, row, index, field){
- return {
- css: {
- "white-space": "nowrap",
- "text-overflow": "ellipsis",
- "overflow": "hidden",
- "max-width":"200px"
- }
- };
- }
- },
- {field: 'thum', title: __('Thum'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
- {field: 'weigh', title: __('Weigh'), operate: false},
- {field: 'status', title: __('Status'), searchList: {"1":__('上架'),"0":__('下架')}, formatter: Table.api.formatter.toggle},
- {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
- {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
- {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- // 修改添加窗口的大小
- $(".btn-add").data("area", ["60%", "80%"]);
- table.on('post-body.bs.table',function () {
- $('.btn-editone').data("area",["80%","100%"]);
- });
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- let dataCode = [];
- if((Config.areaCode).length > 0) dataCode = JSON.parse(Config.areaCode);
- new Vue({
- el: '#app',
- data() {
- return {
- data: dataCode,
- props: { multiple: true },
- options:area
- };
- },
- methods:{
- handleChange(e){
- let txt = this.$refs.ca.getCheckedNodes(),txtArr = Array();
- txt.forEach(vv => {
- txtArr.push($.makeArray((vv.pathLabels).join('-')) );
- });
- $('#c-product_area').val(JSON.stringify(this.data))
- $('#c-product_area_txt').val(JSON.stringify(txtArr))
-
- }}
- })
- },
- }
- };
- return Controller;
- });
|