edit.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. <?php
  2. use common\helpers\ComponentHelper;
  3. ComponentHelper::loadComponentView('com-select-cat');
  4. ComponentHelper::loadComponentView('com-dialog-select');
  5. ComponentHelper::loadComponentView('com-rich-text');
  6. ComponentHelper::loadComponentView('com-image');
  7. ComponentHelper::loadComponentView('com-rich-text');
  8. ?>
  9. <script src="/resources/js/Sortable.min.js"></script>
  10. <script src="/resources/unpkg/vuedraggable@2.18.1/dist/vuedraggable.umd.min.js"></script>
  11. <div id="app" v-cloak>
  12. <el-card class="box-card" shadow="never" style="border:0;min-width: 1200px;"
  13. body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  14. <div slot="header">
  15. <el-breadcrumb separator="/">
  16. <el-breadcrumb-item>
  17. <span style="color: #409EFF;cursor: pointer"
  18. @click="$navigate({r:'electron-coupon/default/index'})">
  19. 名片
  20. </span>
  21. </el-breadcrumb-item>
  22. <el-breadcrumb-item>{{titleName}}</el-breadcrumb-item>
  23. </el-breadcrumb>
  24. </div>
  25. <div class="form-body" v-loading="loading">
  26. <el-form :model="submitData" :rules="rules" ref="ruleForm" size="small" label-width="150px" style="margin-left: 20px;">
  27. <el-form-item label="分类名称" style="margin-bottom: 20px;" required label-width="100px">
  28. <el-input placeholder="请输入分类名称" type="text" v-model="submitData.name"></el-input>
  29. </el-form-item>
  30. <el-form-item label="排序" style="margin-bottom: 20px;" required label-width="100px">
  31. <el-input placeholder="请输入数值" type="number" v-model="submitData.order_sort"></el-input>
  32. </el-form-item>
  33. <el-form-item label="是否启用" style="margin-bottom: 20px" required label-width="100px">
  34. <el-switch
  35. v-model="submitData.status"
  36. :active-value="1"
  37. :inactive-value="0"
  38. >
  39. </el-switch>
  40. </el-form-item>
  41. </div>
  42. <el-button class="button-item" :loading="btnLoading" type="primary" @click="saveFun"
  43. size="small">保存
  44. </el-button>
  45. </el-card>
  46. </div>
  47. <script>
  48. const app = new Vue({
  49. el: '#app',
  50. data() {
  51. return {
  52. diy_img_prefix: '<?= Yii::getAlias('@attachurl') ?>',
  53. titleName:"添加素材分类",
  54. loading:false,
  55. foundLoading:false,
  56. keyword_name: '',
  57. keyword_id: '',
  58. keyword_mobile: '',
  59. submitData:{
  60. id: null,
  61. name: null,
  62. order_sort: 0,
  63. status: 1
  64. },
  65. rules: {
  66. name: [
  67. { required: true, message: '请输入分类名称', trigger: 'blur' }
  68. ],
  69. },
  70. btnLoading:false,
  71. cateList: [],
  72. material_ext_type: [],
  73. };
  74. },
  75. mounted() {
  76. // this.submitData.updated_at = Date.parse(new Date()) / 1000; // 新建数据的更新时间
  77. if (getQuery('id')) {
  78. this.titleName="编辑素材分类";
  79. this.loadData(getQuery('id'));
  80. } else {
  81. // this.submitData.created_at = Date.parse(new Date()) / 1000; // 新建数据的创建时间
  82. }
  83. this.getExtType();
  84. this.getCate();
  85. },
  86. watch:{
  87. },
  88. computed:
  89. {
  90. link_title() {
  91. let arr = this.submitData.material_link.split('/');
  92. let title = arr.pop();
  93. return title ? title : '';
  94. }
  95. },
  96. methods: {
  97. getCate() {
  98. request({
  99. params: {
  100. r: 'business-card/material/cate-list'
  101. }
  102. }).then(e=>{
  103. if (e.data.code == 0) {
  104. this.cateList = e.data.data;
  105. }
  106. }).catch(e=>{
  107. })
  108. },
  109. getSelImg(val){
  110. console.info(val);
  111. this.submitData.cover_img = val[0];
  112. },
  113. delSelImg(){
  114. //this.submitData.cover_img.splice(index, 1);
  115. this.submitData.cover_img = '';
  116. },
  117. videoUrl(e) {
  118. if (e.length) {
  119. //this.submitData.material_link = e[0].url;
  120. this.$set(this.submitData, 'material_link', e[0].url);
  121. }
  122. console.log(e[0]);
  123. // console.log(this.submitData);
  124. this.$forceUpdate();
  125. },
  126. pdfUrl(e) {
  127. console.log(e[0]);
  128. if (e.length) {
  129. //this.submitData.material_link = e[0].url;
  130. this.$set(this.submitData, 'material_link', e[0].url);
  131. // console.log(this.submitData.material_link)
  132. }
  133. },
  134. viewPdf() {
  135. window.open(
  136. this.submitData.material_link
  137. )
  138. },
  139. getUser() {
  140. let self = this;
  141. self.userDialog.loading = true;
  142. request({
  143. params: {
  144. r: 'business-bonus/default/search-user',
  145. page: self.userDialog.page,
  146. keyword_name: this.keyword_name,
  147. keyword_id: this.keyword_id,
  148. keyword_mobile: this.keyword_mobile,
  149. type:this.userDialog.index,
  150. },
  151. method: 'get',
  152. }).then(e => {
  153. self.userDialog.loading = false;
  154. self.userDialog.list = e.data.data.list;
  155. self.userDialog.pagination = e.data.data.pagination;
  156. }).catch(e => {
  157. console.log(e);
  158. });
  159. },
  160. addUser()
  161. {
  162. if (this.userDialog.selectedList && this.userDialog.selectedList.length > 1) {
  163. this.$message.error('只能选择一个用户!');
  164. return false;
  165. }
  166. this.submitData.nickname = this.userDialog.selectedList[0].nickname;
  167. this.submitData.user_id = this.userDialog.selectedList[0].id;
  168. this.submitData.mobile = this.userDialog.selectedList[0].mobile;
  169. this.submitData.avatar_url = this.userDialog.selectedList[0].avatar_url;
  170. this.userDialog.visible = false;
  171. },
  172. userSelectionChange(e) {
  173. if (e.length > 1) {
  174. this.$message.error('只能选择一个用户!');
  175. }
  176. this.userDialog.selectedList = e;
  177. },
  178. userDialogPageChange(page) {
  179. this.userDialog.page = page;
  180. this.getUser();
  181. },
  182. showUserDialog(index) {
  183. this.userDialog.visible = true;
  184. this.userDialog.index = index;
  185. },
  186. saveFun(){
  187. this.$refs['ruleForm'].validate((valid) => {
  188. if (valid) {
  189. if (!this.submitData.name) {
  190. this.$message.error('请输入分类名称!');
  191. return false;
  192. }
  193. let data =JSON.parse(JSON.stringify(this.submitData));
  194. this.btnLoading = true;
  195. let url = 'business-card/material-cate/edit';
  196. request({
  197. params: {
  198. r:url,
  199. },
  200. method: 'post',
  201. data: data
  202. }).then(e => {
  203. this.btnLoading = false;
  204. if (e.data.code == 0) {
  205. this.$message.success(e.data.msg);
  206. setTimeout(function () {
  207. navigateTo({
  208. r: 'business-card/material-cate/index',
  209. });
  210. }, 1500);
  211. } else {
  212. this.$message.error(e.data.msg);
  213. }
  214. }).catch(e => {
  215. this.$message.error(e);
  216. this.btnLoading = false;
  217. })
  218. } else {
  219. this.$message.error('请填写必要的参数!');
  220. return false;
  221. }
  222. });
  223. },
  224. picUrl(e) {
  225. if (e.length) {
  226. this.submitData.pic = e[0].url;
  227. }
  228. },
  229. delPic(index) {
  230. /* this.pic_url.splice(index, 1) */
  231. this.submitData.pic = '';
  232. },
  233. receiveDatetimeChange(){
  234. if(this.receive_datetime){
  235. this.submitData.receive_begin_time = Date.parse(new Date(this.receive_datetime[0]).toString())/1000;
  236. this.submitData.receive_end_time = Date.parse(new Date(this.receive_datetime[1]).toString())/1000;
  237. }
  238. },
  239. useDatetimeChange() {
  240. if(this.use_datetime){
  241. this.submitData.use_begin_time = Date.parse(new Date(this.use_datetime[0]).toString())/1000;
  242. this.submitData.use_end_time = Date.parse(new Date(this.use_datetime[1]).toString())/1000;
  243. }
  244. },
  245. addPrize(){
  246. this.submitData.prize.push(JSON.parse(JSON.stringify(this.prizeObj)));
  247. },
  248. delPrize(index){
  249. this.submitData.prize.splice(index,1)
  250. },
  251. formatTime(timeStamp) {
  252. var date = new Date();
  253. date.setTime(timeStamp * 1000);
  254. var y = date.getFullYear();
  255. var m = date.getMonth() + 1;
  256. m = m < 10 ? ('0' + m) : m;
  257. var d = date.getDate();
  258. d = d < 10 ? ('0' + d) : d;
  259. var h = date.getHours();
  260. h = h < 10 ? ('0' + h) : h;
  261. var minute = date.getMinutes();
  262. var second = date.getSeconds();
  263. minute = minute < 10 ? ('0' + minute) : minute;
  264. second = second < 10 ? ('0' + second) : second;
  265. return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + second;
  266. },
  267. loadData(id){
  268. this.loading = true;
  269. request({
  270. params: {
  271. r:'business-card/material-cate/info',
  272. id: id
  273. },
  274. method: 'get',
  275. }).then(e => {
  276. this.loading = false;
  277. if (e.data.code == 0) {
  278. if (e.data.data.is_null == 0) {
  279. this.submitData = e.data.data.info;
  280. }
  281. } else {
  282. this.$message.error(e.data.msg);
  283. }
  284. }).catch(e => {
  285. this.loading = false;
  286. });
  287. },
  288. getExtType() {
  289. request({
  290. params: {
  291. r:'business-card/material/ext-type',
  292. },
  293. method: 'post',
  294. }).then(e => {
  295. if (e.data.code == 0) {
  296. this.material_ext_type = e.data.data;
  297. } else {
  298. this.$message.error(e.data.msg);
  299. }
  300. }).catch(e => {
  301. });
  302. }
  303. }
  304. });
  305. </script>
  306. <style>
  307. .form-body {
  308. padding: 20px;
  309. background-color: #fff;
  310. margin-bottom: 20px;
  311. padding-right: 20%;
  312. min-width: 900px;
  313. }
  314. .form-body .el-form-item {
  315. padding-right: 25%;
  316. min-width: 850px;
  317. }
  318. .form-button {
  319. margin: 0;
  320. }
  321. .form-button .el-form-item__content {
  322. margin-left: 0 !important;
  323. }
  324. .button-item {
  325. padding: 9px 25px;
  326. }
  327. .check-group {
  328. font-size: 14px !important;
  329. }
  330. .check-group .el-col {
  331. display: flex;
  332. }
  333. .check-group .el-input {
  334. margin: 0 5px;
  335. }
  336. .check-group .el-col .el-checkbox {
  337. display: flex;
  338. align-items: center;
  339. }
  340. .check-group .el-col .el-input {
  341. width: 100px;
  342. }
  343. .check-group .el-col .el-input .el-input__inner {
  344. height: 30px;
  345. width: 100px;
  346. }
  347. .el-checkbox-group .el-col {
  348. margin-bottom: 10px;
  349. }
  350. .add-image-btn {
  351. width: 100px;
  352. height: 100px;
  353. color: #419EFB;
  354. border: 1px solid #e2e2e2;
  355. cursor: pointer;
  356. }
  357. .remark {
  358. color: #cccccc;
  359. }
  360. .user-info img {
  361. width: 60px;
  362. border-radius: 50%;
  363. margin-top: 10px;
  364. }
  365. /*批量上传图片*/
  366. .pic-url-remark {
  367. font-size: 13px;
  368. color: #c9c9c9;
  369. margin-bottom: 12px;
  370. }
  371. .add-image-btn {
  372. width: 100px;
  373. height: 100px;
  374. color: #419EFB;
  375. border: 1px solid #e2e2e2;
  376. cursor: pointer;
  377. }
  378. .del-btn-pro{
  379. position: absolute;
  380. top: 28%;
  381. left: 57px;
  382. }
  383. .del-btn{
  384. position: absolute;
  385. top: -10%;
  386. right: -12%;
  387. z-index: 10;
  388. }
  389. .el-button--mini.is-circle{
  390. padding: 4px;
  391. }
  392. .priview-title{
  393. margin-bottom: 16px;
  394. font-size: 20px;
  395. font-weight: bold;
  396. color: #000000;
  397. }
  398. .priview-center{
  399. margin: 16px 11px;
  400. height: 86%;
  401. overflow-y: auto;
  402. }
  403. .preview-model{
  404. margin-right: 15px;
  405. background: #FFF;
  406. min-width: 375px;
  407. max-width: 375px;
  408. height: 78vh;
  409. overflow-wrap: anywhere;
  410. border-radius: 5px;
  411. }
  412. .form-right{
  413. flex: 1;
  414. overflow: auto;
  415. height: 78vh;
  416. }
  417. .card-model{
  418. border: 0;
  419. margin-bottom: 10px;
  420. }
  421. .customize-share-title{
  422. position: relative;
  423. display: inline-block;
  424. margin: 10px 10px 0 0;
  425. }
  426. .dp-header-placeholder {
  427. width: 100%;
  428. height: 44px;
  429. background-size: 100% 100%;
  430. z-index: 99;
  431. background: url("resources/img/decorate/nav/light1.png") no-repeat;
  432. }
  433. .preview-top-title{
  434. width: 100%;
  435. height: 24px;
  436. text-align: center;
  437. line-height: 24px;
  438. font-size: 16px;
  439. font-weight: 600;
  440. }
  441. /* 富文本表格样式 */
  442. .rich-text .note-app table {
  443. border-top: 1px solid #ccc;
  444. border-left: 1px solid #ccc;
  445. }
  446. .rich-text .note-app table th {
  447. background-color: #f1f1f1;
  448. }
  449. .rich-text .note-app table th,
  450. .rich-text .note-app table td {
  451. border-bottom: 1px solid #ccc;
  452. text-align: center;
  453. border-right: 1px solid #ccc;
  454. padding: 3px 5px;
  455. min-height: 30px;
  456. height: 30px;
  457. }
  458. .form-right::-webkit-scrollbar-thumb,.priview-center::-webkit-scrollbar-thumb{
  459. width: 4px;
  460. }
  461. </style>