| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543 |
- <?php
- use common\helpers\ComponentHelper;
- ComponentHelper::loadComponentView('com-select-cat');
- ComponentHelper::loadComponentView('com-dialog-select');
- ComponentHelper::loadComponentView('com-rich-text');
- ComponentHelper::loadComponentView('com-image');
- ComponentHelper::loadComponentView('com-rich-text');
- ?>
- <script src="/resources/js/Sortable.min.js"></script>
- <script src="/resources/unpkg/vuedraggable@2.18.1/dist/vuedraggable.umd.min.js"></script>
- <div id="app" v-cloak>
- <el-card class="box-card" shadow="never" style="border:0;min-width: 1200px;"
- body-style="background-color: #f3f3f3;padding: 10px 0 0;">
- <div slot="header">
- <el-breadcrumb separator="/">
- <el-breadcrumb-item>
- <span style="color: #409EFF;cursor: pointer"
- @click="$navigate({r:'electron-coupon/default/index'})">
- 名片
- </span>
- </el-breadcrumb-item>
- <el-breadcrumb-item>{{titleName}}</el-breadcrumb-item>
- </el-breadcrumb>
- </div>
- <div class="form-body" v-loading="loading">
- <el-form :model="submitData" :rules="rules" ref="ruleForm" size="small" label-width="150px" style="margin-left: 20px;">
- <el-form-item label="分类名称" style="margin-bottom: 20px;" required label-width="100px">
- <el-input placeholder="请输入分类名称" type="text" v-model="submitData.name"></el-input>
- </el-form-item>
- <el-form-item label="排序" style="margin-bottom: 20px;" required label-width="100px">
- <el-input placeholder="请输入数值" type="number" v-model="submitData.order_sort"></el-input>
- </el-form-item>
- <el-form-item label="是否启用" style="margin-bottom: 20px" required label-width="100px">
- <el-switch
- v-model="submitData.status"
- :active-value="1"
- :inactive-value="0"
- >
- </el-switch>
- </el-form-item>
- </div>
- <el-button class="button-item" :loading="btnLoading" type="primary" @click="saveFun"
- size="small">保存
- </el-button>
- </el-card>
- </div>
- <script>
- const app = new Vue({
- el: '#app',
- data() {
- return {
- diy_img_prefix: '<?= Yii::getAlias('@attachurl') ?>',
- titleName:"添加素材分类",
- loading:false,
- foundLoading:false,
- keyword_name: '',
- keyword_id: '',
- keyword_mobile: '',
- submitData:{
- id: null,
- name: null,
- order_sort: 0,
- status: 1
- },
- rules: {
- name: [
- { required: true, message: '请输入分类名称', trigger: 'blur' }
- ],
- },
- btnLoading:false,
- cateList: [],
- material_ext_type: [],
- };
- },
- mounted() {
- // this.submitData.updated_at = Date.parse(new Date()) / 1000; // 新建数据的更新时间
- if (getQuery('id')) {
- this.titleName="编辑素材分类";
- this.loadData(getQuery('id'));
- } else {
- // this.submitData.created_at = Date.parse(new Date()) / 1000; // 新建数据的创建时间
- }
- this.getExtType();
- this.getCate();
- },
- watch:{
- },
- computed:
- {
- link_title() {
- let arr = this.submitData.material_link.split('/');
- let title = arr.pop();
- return title ? title : '';
- }
- },
- methods: {
- getCate() {
- request({
- params: {
- r: 'business-card/material/cate-list'
- }
- }).then(e=>{
- if (e.data.code == 0) {
- this.cateList = e.data.data;
- }
- }).catch(e=>{
- })
- },
- getSelImg(val){
- console.info(val);
- this.submitData.cover_img = val[0];
- },
- delSelImg(){
- //this.submitData.cover_img.splice(index, 1);
- this.submitData.cover_img = '';
- },
- videoUrl(e) {
- if (e.length) {
- //this.submitData.material_link = e[0].url;
- this.$set(this.submitData, 'material_link', e[0].url);
- }
- console.log(e[0]);
- // console.log(this.submitData);
- this.$forceUpdate();
- },
- pdfUrl(e) {
- console.log(e[0]);
- if (e.length) {
- //this.submitData.material_link = e[0].url;
- this.$set(this.submitData, 'material_link', e[0].url);
- // console.log(this.submitData.material_link)
- }
- },
- viewPdf() {
- window.open(
- this.submitData.material_link
- )
- },
- getUser() {
- let self = this;
- self.userDialog.loading = true;
- request({
- params: {
- r: 'business-bonus/default/search-user',
- page: self.userDialog.page,
- keyword_name: this.keyword_name,
- keyword_id: this.keyword_id,
- keyword_mobile: this.keyword_mobile,
- type:this.userDialog.index,
- },
- method: 'get',
- }).then(e => {
- self.userDialog.loading = false;
- self.userDialog.list = e.data.data.list;
- self.userDialog.pagination = e.data.data.pagination;
- }).catch(e => {
- console.log(e);
- });
- },
- addUser()
- {
- if (this.userDialog.selectedList && this.userDialog.selectedList.length > 1) {
- this.$message.error('只能选择一个用户!');
- return false;
- }
- this.submitData.nickname = this.userDialog.selectedList[0].nickname;
- this.submitData.user_id = this.userDialog.selectedList[0].id;
- this.submitData.mobile = this.userDialog.selectedList[0].mobile;
- this.submitData.avatar_url = this.userDialog.selectedList[0].avatar_url;
- this.userDialog.visible = false;
- },
- userSelectionChange(e) {
- if (e.length > 1) {
- this.$message.error('只能选择一个用户!');
- }
- this.userDialog.selectedList = e;
- },
- userDialogPageChange(page) {
- this.userDialog.page = page;
- this.getUser();
- },
- showUserDialog(index) {
- this.userDialog.visible = true;
- this.userDialog.index = index;
- },
- saveFun(){
- this.$refs['ruleForm'].validate((valid) => {
- if (valid) {
- if (!this.submitData.name) {
- this.$message.error('请输入分类名称!');
- return false;
- }
- let data =JSON.parse(JSON.stringify(this.submitData));
- this.btnLoading = true;
- let url = 'business-card/material-cate/edit';
- request({
- params: {
- r:url,
- },
- method: 'post',
- data: data
- }).then(e => {
- this.btnLoading = false;
- if (e.data.code == 0) {
- this.$message.success(e.data.msg);
- setTimeout(function () {
- navigateTo({
- r: 'business-card/material-cate/index',
- });
- }, 1500);
- } else {
- this.$message.error(e.data.msg);
- }
- }).catch(e => {
- this.$message.error(e);
- this.btnLoading = false;
- })
- } else {
- this.$message.error('请填写必要的参数!');
- return false;
- }
- });
- },
- picUrl(e) {
- if (e.length) {
- this.submitData.pic = e[0].url;
- }
- },
- delPic(index) {
- /* this.pic_url.splice(index, 1) */
- this.submitData.pic = '';
- },
- receiveDatetimeChange(){
- if(this.receive_datetime){
- this.submitData.receive_begin_time = Date.parse(new Date(this.receive_datetime[0]).toString())/1000;
- this.submitData.receive_end_time = Date.parse(new Date(this.receive_datetime[1]).toString())/1000;
- }
- },
- useDatetimeChange() {
- if(this.use_datetime){
- this.submitData.use_begin_time = Date.parse(new Date(this.use_datetime[0]).toString())/1000;
- this.submitData.use_end_time = Date.parse(new Date(this.use_datetime[1]).toString())/1000;
- }
- },
- addPrize(){
- this.submitData.prize.push(JSON.parse(JSON.stringify(this.prizeObj)));
- },
- delPrize(index){
- this.submitData.prize.splice(index,1)
- },
- formatTime(timeStamp) {
- var date = new Date();
- date.setTime(timeStamp * 1000);
- var y = date.getFullYear();
- var m = date.getMonth() + 1;
- m = m < 10 ? ('0' + m) : m;
- var d = date.getDate();
- d = d < 10 ? ('0' + d) : d;
- var h = date.getHours();
- h = h < 10 ? ('0' + h) : h;
- var minute = date.getMinutes();
- var second = date.getSeconds();
- minute = minute < 10 ? ('0' + minute) : minute;
- second = second < 10 ? ('0' + second) : second;
- return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + second;
- },
- loadData(id){
- this.loading = true;
- request({
- params: {
- r:'business-card/material-cate/info',
- id: id
- },
- method: 'get',
- }).then(e => {
- this.loading = false;
- if (e.data.code == 0) {
- if (e.data.data.is_null == 0) {
- this.submitData = e.data.data.info;
- }
- } else {
- this.$message.error(e.data.msg);
- }
- }).catch(e => {
- this.loading = false;
- });
- },
- getExtType() {
- request({
- params: {
- r:'business-card/material/ext-type',
- },
- method: 'post',
- }).then(e => {
- if (e.data.code == 0) {
- this.material_ext_type = e.data.data;
- } else {
- this.$message.error(e.data.msg);
- }
- }).catch(e => {
- });
- }
- }
- });
- </script>
- <style>
- .form-body {
- padding: 20px;
- background-color: #fff;
- margin-bottom: 20px;
- padding-right: 20%;
- min-width: 900px;
- }
- .form-body .el-form-item {
- padding-right: 25%;
- min-width: 850px;
- }
- .form-button {
- margin: 0;
- }
- .form-button .el-form-item__content {
- margin-left: 0 !important;
- }
- .button-item {
- padding: 9px 25px;
- }
- .check-group {
- font-size: 14px !important;
- }
- .check-group .el-col {
- display: flex;
- }
- .check-group .el-input {
- margin: 0 5px;
- }
- .check-group .el-col .el-checkbox {
- display: flex;
- align-items: center;
- }
- .check-group .el-col .el-input {
- width: 100px;
- }
- .check-group .el-col .el-input .el-input__inner {
- height: 30px;
- width: 100px;
- }
- .el-checkbox-group .el-col {
- margin-bottom: 10px;
- }
- .add-image-btn {
- width: 100px;
- height: 100px;
- color: #419EFB;
- border: 1px solid #e2e2e2;
- cursor: pointer;
- }
- .remark {
- color: #cccccc;
- }
- .user-info img {
- width: 60px;
- border-radius: 50%;
- margin-top: 10px;
- }
- /*批量上传图片*/
- .pic-url-remark {
- font-size: 13px;
- color: #c9c9c9;
- margin-bottom: 12px;
- }
- .add-image-btn {
- width: 100px;
- height: 100px;
- color: #419EFB;
- border: 1px solid #e2e2e2;
- cursor: pointer;
- }
- .del-btn-pro{
- position: absolute;
- top: 28%;
- left: 57px;
- }
- .del-btn{
- position: absolute;
- top: -10%;
- right: -12%;
- z-index: 10;
- }
- .el-button--mini.is-circle{
- padding: 4px;
- }
- .priview-title{
- margin-bottom: 16px;
- font-size: 20px;
- font-weight: bold;
- color: #000000;
- }
- .priview-center{
- margin: 16px 11px;
- height: 86%;
- overflow-y: auto;
- }
- .preview-model{
- margin-right: 15px;
- background: #FFF;
- min-width: 375px;
- max-width: 375px;
- height: 78vh;
- overflow-wrap: anywhere;
- border-radius: 5px;
- }
- .form-right{
- flex: 1;
- overflow: auto;
- height: 78vh;
- }
- .card-model{
- border: 0;
- margin-bottom: 10px;
- }
- .customize-share-title{
- position: relative;
- display: inline-block;
- margin: 10px 10px 0 0;
- }
- .dp-header-placeholder {
- width: 100%;
- height: 44px;
- background-size: 100% 100%;
- z-index: 99;
- background: url("resources/img/decorate/nav/light1.png") no-repeat;
- }
- .preview-top-title{
- width: 100%;
- height: 24px;
- text-align: center;
- line-height: 24px;
- font-size: 16px;
- font-weight: 600;
- }
- /* 富文本表格样式 */
- .rich-text .note-app table {
- border-top: 1px solid #ccc;
- border-left: 1px solid #ccc;
- }
- .rich-text .note-app table th {
- background-color: #f1f1f1;
- }
- .rich-text .note-app table th,
- .rich-text .note-app table td {
- border-bottom: 1px solid #ccc;
- text-align: center;
- border-right: 1px solid #ccc;
- padding: 3px 5px;
- min-height: 30px;
- height: 30px;
- }
- .form-right::-webkit-scrollbar-thumb,.priview-center::-webkit-scrollbar-thumb{
- width: 4px;
- }
- </style>
|