com-pick-link.php 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962
  1. <?php
  2. use common\helpers\ComponentHelper;
  3. //ComponentHelper::loadComponentView('com-pick-list');
  4. ?>
  5. <style>
  6. .com-pick-link .el-checkbox+.el-checkbox {
  7. margin-left: 0;
  8. }
  9. .com-pick-link .checkbox-div-box {
  10. height: 350px;
  11. overflow: auto;
  12. }
  13. .com-pick-link .edit-img {
  14. width: 18px;
  15. height: 18px;
  16. display: inline-block;
  17. margin-left: 10px;
  18. cursor: pointer;
  19. }
  20. .com-pick-link .el-dialog {
  21. width: 900px;
  22. }
  23. .com-pick-link .pick-box {
  24. width: 860px;
  25. }
  26. .auto-width .el-dialog {
  27. width: 80%;
  28. min-width: 900px;
  29. ;
  30. }
  31. .auto-width .pick-box {
  32. width: 99%;
  33. min-width: 860px;
  34. }
  35. .com-pick-link .el-checkbox {
  36. margin-right: 0;
  37. height: 32px;
  38. }
  39. .com-pick-link .el-checkbox__input {
  40. margin-top: 4px;
  41. }
  42. .module-box {
  43. width: 100%;
  44. height: 400px;
  45. border: 1px solid #f1f1f1;
  46. border-radius: 4px;
  47. padding: 10px 0;
  48. overflow: auto;
  49. }
  50. .right-box {
  51. padding: 10px;
  52. }
  53. .module-box-li li {
  54. width: 100%;
  55. height: 36px;
  56. line-height: 36px;
  57. text-indent: 30px;
  58. font-size: 14px;
  59. cursor: pointer;
  60. }
  61. .module-box-li li:hover {
  62. color: #409eff;
  63. }
  64. .module-box-li .active {
  65. background-color: #e5f0fe;
  66. }
  67. .cate3 {
  68. margin-left: 5px;
  69. padding: 15px 0 10px 0;
  70. color: #666;
  71. }
  72. </style>
  73. <template id="com-pick-link">
  74. <div>
  75. <el-dialog class="com-pick-link" :class="autoWidth && 'auto-width'" :title="title ? title : '选择链接'" @close="closeDialog" :visible.sync="dialogFormVisible" @opened="dialogOpened" :close-on-click-modal="false" :modal-append-to-body="false" append-to-body>
  76. <el-form v-loading="loading" :rules="form_rules" size="small" @submit.native.prevent label-width="60px">
  77. <div flex="main:justify">
  78. <div class="pick-box">
  79. <el-card class="box-card" shadow="never">
  80. <el-tabs v-model="activeName" type="card" @tab-click="tabsClick">
  81. <el-tab-pane v-for="category1 in options" :label="category1.title" :key="category1.name" :name="category1.name">
  82. <el-row :gutter="10">
  83. <el-col :span="6">
  84. <div class="module-box module-box-li">
  85. <ul>
  86. <li class="left-li" :data-arr="category2.id +','+ category2.name +','+ category2.is_list" v-for="category2,key2 in category1.children" :key="category2.id" :class="[key2 == 0 ? 'active' : '','left-li-' + category2.id]" @click="liActive(category2,category1.name)">{{ category2.title }}</li>
  87. </ul>
  88. </div>
  89. </el-col>
  90. <el-col :span="18">
  91. <div class="module-box right-box">
  92. <div v-for="category2 in category1.children" :key="category2.id">
  93. <!-- 右侧模块 -->
  94. <div v-if="childrenBoxShow == category2.id && category2.is_list == 0" class="children-box">
  95. <div class="input-item top-input" style="margin-bottom: 10px;width: 300px;" v-if="['base', 'application'].indexOf(category2.name) !== -1">
  96. <el-input @keyup.enter.native="searchByType(category2.name)" size="small" placeholder="请输入搜索内容" type="text" clearable @clear="searchByType(category2.name)" v-model="searchKeyword">
  97. <el-button slot="append" @click="searchByType(category2.name)" icon="el-icon-search"></el-button>
  98. </el-input>
  99. </div>
  100. <el-alert v-if="category2.remark" :title="category2.remark" type="info"></el-alert>
  101. <!-- 其他 -->
  102. <div v-if="category1.name == 'other'" style="margin-top: 15px">
  103. <el-form @submit.native.prevent>
  104. <div v-if="category2.name == 'applet_link'">
  105. <!--小程序-->
  106. <el-form-item label-width="100px"
  107. label="小程序类型"
  108. style="margin-bottom: 15px;">
  109. <el-radio-group v-model="appletChangeType"
  110. @input="appletTypeChange(link[category2.id], $event)">
  111. <el-radio label="wechatApplet">微信小程序</el-radio>
  112. <el-radio label="alipayApplet">支付宝小程序</el-radio>
  113. </el-radio-group>
  114. </el-form-item>
  115. <el-form-item
  116. v-for="(item, key) in appletList"
  117. label-width="100px" :key="item.id"
  118. :label="item.title"
  119. style="margin-bottom: 15px;">
  120. <el-input style="margin-bottom: 10px" v-model="item.route" v-if="item.name == 'mp_ali_appid'" @input="appletInputLink($event, item)" type="textarea"
  121. :rows="5" placeholder="粘贴格式 alipays://platformapi/startapp?appId=2019062465587961&page=pages%2Fhz-enjoy%2Fmain%2Findex%3FextraData%3D%7B%22templateId%22%3A%22ZMGO_TPL202304061002000227790%22%2C%22partnerId%22%3A%222088041787152715%22%2C%22appId%22%3A%222021001181622762%22%7D 将自动解析APPID及路径"></el-input>
  122. <el-input v-else :placeholder="item.remark" v-model="item.route" @input="appletInputLink($event, item)"></el-input>
  123. </el-form-item>
  124. </div>
  125. <div v-else>
  126. <el-form-item v-for="(item, key) in link[category2.id]" label-width="100px" :key="item.id" :label="item.title" style="margin-bottom: 15px;">
  127. <template v-if="category2.name == 'wechat_video_account' && item.name == 'jumpType'">
  128. <el-radio-group v-model="item.route" v-if="item.name == 'jumpType'" @input="otherInputLink($event, item, link[category2.id])">
  129. <el-radio label="channelsUserProfile">主页</el-radio>
  130. <el-radio label="channelsActivity">视频</el-radio>
  131. <el-radio label="channelsLive">直播</el-radio>
  132. </el-radio-group>
  133. </template>
  134. <template v-else>
  135. <template v-if="item.name == 'feedId'">
  136. <el-input :placeholder="item.remark" v-model="item.route" :autosize="{ minRows: 4, maxRows: 8}" @input="otherInputLink($event, item, link[category2.id])" type="textarea"> </el-input>
  137. </template>
  138. <template v-else>
  139. <el-input :placeholder="item.remark" v-model="item.route" @input="otherInputLink($event, item, link[category2.id])">
  140. <template v-if="item.open_type == 'call'" slot="prepend">电话</template>
  141. </el-input>
  142. </template>
  143. </template>
  144. </el-form-item>
  145. </div>
  146. </el-form>
  147. </div>
  148. <!-- 按钮模块 -->
  149. <div v-else>
  150. <div v-for="category3 in category2.children" :key="category3.name">
  151. <div class="cate3" v-if="link[category3.id] !== undefined && link[category3.id].length > 0"><i class="el-icon-notebook-2"></i> <span>{{ category3.title }}</span></div>
  152. <el-button plain v-for="(item, key) in link[category3.id]" :key="key" size="small" @click="selectBtn(item)" style="margin: 5px;">{{item.title}}</el-button>
  153. </div>
  154. </div>
  155. </div>
  156. <!-- 链接列表 -->
  157. <div v-if="childrenBoxShow == category2.id && category2.is_list == 1&&category2.name !== 'consumer_card'" class="children-box">
  158. <div style="display: flex; align-items: center; margin-bottom: 10px;">
  159. <div class="input-item top-input" style="width: 300px;">
  160. <el-input @keyup.enter.native="searchForm" size="small" placeholder="请输入搜索内容" type="text" clearable @clear="searchForm" v-model="keyword">
  161. <el-button slot="append" @click="searchForm" icon="el-icon-search"></el-button>
  162. </el-input>
  163. </div>
  164. <el-select v-model="cateValue" placeholder="请选择分类" size="small" clearable @change="searchForm"
  165. v-if="(category2.name == 'goods_cate' || category2.name == 'store-commodity-cate') && isShowGoodsCateSelect" style="margin-left: 10px;">
  166. <el-option label="一级分类" value="1"></el-option>
  167. <el-option label="二级分类" value="2"></el-option>
  168. <el-option label="三级分类" value="3"></el-option>
  169. </el-select>
  170. </div>
  171. <div v-if="boxList.length > 0">
  172. <el-table ref="multipleGoodsTable" :data="boxList" tooltip-effect="dark" border v-loading="boxListLoading" size="small" @selection-change="handleSelectionChange" :row-key="getRowKeys">
  173. <el-table-column v-if="inPickType == 1 || getIsJd" type="selection" reserve-selection width="55">
  174. </el-table-column>
  175. <el-table-column prop="id" :label="`${idText}${showId ? 'ID' : ''}`" width="100">
  176. <template slot-scope="scope">
  177. <span v-if="inPickType == 1">{{ scope.row.id }}</span>
  178. <span v-else-if="getIsJd">{{ scope.row.id }}</span>
  179. <div v-else>
  180. <el-radio v-model="pick_value" :label="scope.row" @change="handleChange">
  181. <span v-show="showId">{{ scope.row.id }}</span>
  182. </el-radio>
  183. </div>
  184. </template>
  185. </el-table-column>
  186. <el-table-column v-if="category2.name !== 'store_coupons'" prop="title" label="标题">
  187. <template slot-scope="scope">
  188. <div flex="cross:center">
  189. <div v-if="scope.row.header" style="margin-right: 10px;">
  190. <el-image style="width: 50px; height: 50px;border-radius: 5px;" :src="scope.row.header"></el-image>
  191. </div>
  192. <div v-if="scope.row.img || scope.row.cover_pic" style="margin-right: 10px;">
  193. <el-image style="width: 50px; height: 50px;border-radius: 5px;" :src="scope.row.img || scope.row.cover_pic"></el-image>
  194. </div>
  195. <div>
  196. <el-tooltip class="item" effect="dark" placement="top">
  197. <div slot="content">{{scope.row.title || scope.row.goods_name||scope.row.name}}</div>
  198. <span>{{`${(scope.row.title || scope.row.goods_name||scope.row.name)} ${scope.row.level_name ? `(${scope.row.level_name})` : ''}`}}</span>
  199. </el-tooltip>
  200. </div>
  201. </div>
  202. </template>
  203. </el-table-column>
  204. <template v-if="category2.name == 'store-commodity-cate' || category2.name == 'store_goods' || category2.name == 'store_renov_goods'">
  205. <el-table-column prop="store_name" label="门店名称"> </el-table-column>
  206. <el-table-column prop="store_id" label="门店ID" width="80px"></el-table-column>
  207. </template>
  208. <template v-if="category2.name == 'store_renov_goods'">
  209. <el-table-column prop="store_name" label="门店名称"></el-table-column>
  210. </template>
  211. <template v-if="category2.name == 'store_coupons'">
  212. <el-table-column prop="name" label="优惠券名称"> </el-table-column>
  213. <el-table-column prop="type_text" label="优惠券类型" width="80px"></el-table-column>
  214. <el-table-column prop="content" label="优惠内容" width="80px"></el-table-column>
  215. </template>
  216. <el-table-column v-if="category2.name !== 'store_coupons'" prop="created_at" label="时间">
  217. <template slot-scope="scope">
  218. <div>{{ scope.row.created_at|dateTimeFormat('Y-m-d H:i:s') }}</div>
  219. </template>
  220. </el-table-column>
  221. </el-table>
  222. <div style="text-align: right;margin: 20px 0;" v-if="pageCount">
  223. <el-pagination @current-change="pagination" background layout="prev, pager, next" :page-count="pageCount"></el-pagination>
  224. </div>
  225. </div>
  226. </div>
  227. <div v-if="childrenBoxShow == category2.id && category2.is_list == 1&&category2.name == 'consumer_card'" class="children-box">
  228. <el-table ref="multipleGoodsTable" :data="boxList" tooltip-effect="dark" border v-loading="boxListLoading" size="small" @selection-change="handleSelectionChange" :row-key="getRowKeys">
  229. <el-table-column label="选择">
  230. <template slot-scope="scope">
  231. <div>
  232. <el-radio v-model="pick_value" :label="scope.row" @change="handleChange">
  233. <span v-show="showId">{{ scope.$index + 1 }}</span>
  234. </el-radio>
  235. </div>
  236. </template>
  237. </el-table-column>
  238. </el-table-column>
  239. <el-table-column prop="recharge_money" label="充值金额">
  240. <template slot-scope="scope">
  241. <div>
  242. {{scope.row.recharge_money}}
  243. </div>
  244. </template>
  245. </el-table-column>
  246. <el-table-column prop="reward_money" label="赠送金额">
  247. <template slot-scope="scope">
  248. <div>
  249. {{scope.row.reward_money}}
  250. </div>
  251. </template>
  252. </el-table-column>
  253. <el-table-column prop="type" label="类型">
  254. <template slot-scope="scope">
  255. <div>
  256. <!-- 1:仅奖励一次,2:重复奖励 -->
  257. {{scope.row.type == 1 ? '仅奖励一次' :scope.row.type == 2 ? '重复奖励' : '-'}}
  258. </div>
  259. </template>
  260. </el-table-column>
  261. </el-table>
  262. <div style="text-align: right;margin: 20px 0;" v-if="pageCount">
  263. <el-pagination @current-change="pagination" background layout="prev, pager, next" :page-count="pageCount"></el-pagination>
  264. </div>
  265. </div>
  266. </div>
  267. </div>
  268. </el-col>
  269. </el-row>
  270. </el-tab-pane>
  271. </el-tabs>
  272. </el-card>
  273. </div>
  274. </div>
  275. </el-form>
  276. <div slot="footer" class="dialog-footer">
  277. <el-button @click="closeDialog">取 消</el-button>
  278. <el-button type="primary" @click="confirm">确 定</el-button>
  279. </div>
  280. </el-dialog>
  281. <div class="com-pick-link-content" @click="showPop" style="display: inline-block">
  282. <slot></slot>
  283. </div>
  284. </div>
  285. </template>
  286. <script>
  287. Vue.component('com-pick-link', {
  288. template: '#com-pick-link',
  289. props: {
  290. mallId: {
  291. default: null,
  292. },
  293. pickType: { // 列表选择多个还是单个参数,如:['online_goods','diy'],默认单选
  294. type: Array,
  295. default () {
  296. return []
  297. },
  298. },
  299. title: {
  300. default: '',
  301. },
  302. defaultSelectList: { // 商品多选默认选中列表 传id
  303. type: Array,
  304. default () {
  305. return []
  306. },
  307. },
  308. // 传入数组,数组可字符串和对象 [{name: 'goods',children:['goods_cate'] }]
  309. defaultTabs: { // 选择需要的tabs栏
  310. type: Array,
  311. default () {
  312. return ["mall", "goods", "addons", "other"]
  313. },
  314. },
  315. popBoo: { //不使用插槽,是否开启弹窗
  316. type: Boolean,
  317. default: false
  318. },
  319. showId: { // 单选按钮旁边是否显示id
  320. type: Boolean,
  321. default: true
  322. },
  323. idText: {
  324. type: String,
  325. default: '选择'
  326. },
  327. parameter: {
  328. type: Object,
  329. default: function() {
  330. return {};
  331. }
  332. },
  333. autoWidth: { //设置弹窗宽度自适应,最小宽度900px
  334. type: Boolean,
  335. default: false
  336. },
  337. isDiyMenu:{
  338. type: Boolean,
  339. default: false
  340. },
  341. isShowGoodsCateSelect:{ // 显示商品分类选择
  342. type: Boolean,
  343. default: true
  344. },
  345. },
  346. data() {
  347. return {
  348. dialogFormVisible: false,
  349. loading: true,
  350. boxListLoading: false,
  351. options: [],
  352. link: [],
  353. boxList: [],
  354. boxDataType: '',
  355. activeName: 'mall',
  356. activeType: '',
  357. route: '',
  358. ruleForm: {},
  359. ruturn_value: [],
  360. pageCount: 0,
  361. pick_value: null,
  362. keyword: null,
  363. cateValue: null,
  364. searchKeyword: null,
  365. currentCheckedItem: {}, //当前选择链接
  366. checkedList: [], // 全部选中链接
  367. checkedCities: [],
  368. appletList: [], // 小程序选择链接
  369. appletChangeType: 'wechatApplet', // 小程序选择类型
  370. form_rules: {
  371. key_name: [{
  372. required: true,
  373. message: '请输入名称',
  374. trigger: 'change'
  375. }, ],
  376. },
  377. otherId: -1,
  378. inPickType: 0,
  379. childrenBoxShow: 0,
  380. alipayMiniFullLink: '',
  381. selectedRows: [],
  382. is_store_route: false
  383. };
  384. },
  385. computed: {
  386. getIsJd() {
  387. return this.activeType == 'multi_goods_cate'
  388. },
  389. isFeedId() {
  390. isFeedId
  391. }
  392. },
  393. created() {
  394. // 定义一个变量用于存储路由信息
  395. let store_route = ''
  396. // 获取当前路由信息并赋值给 store_route 变量
  397. store_route = this.$root.currentRoute
  398. // 将路由信息按 '/' 分割成数组
  399. store_route = store_route.split('/')
  400. // 检查路由数组的第一个元素是否为 'store'
  401. if (store_route[0] == 'store') {
  402. // 如果是, 将 is_store_route 属性设置为 true
  403. this.is_store_route = true
  404. }
  405. },
  406. watch: {
  407. popBoo: {
  408. handler(val) {
  409. console.log(val, "==========> ");
  410. this.dialogFormVisible = val;
  411. },
  412. immediate: true
  413. },
  414. alipayMiniFullLink: {
  415. handler(val) {
  416. if (val) {
  417. val = decodeURIComponent(val)
  418. // 解析出来appid及path
  419. val = val.replaceAll('alipays://platformapi/startapp?appId=', '')
  420. let valArr = val.split('&page=')
  421. if (valArr.length === 2) {
  422. for (let linkKey in this.link) {
  423. for (let i in this.link[linkKey]) {
  424. if (this.link[linkKey][i].open_type == 'applet') {
  425. console.log(this.link[linkKey][i].open_type)
  426. switch (this.link[linkKey][i].name) {
  427. case 'mp_ali_appid':
  428. this.link[linkKey][i].route = valArr[0]
  429. break;
  430. case 'mp_ali_app_path':
  431. this.link[linkKey][i].route = valArr[1]
  432. break;
  433. }
  434. }
  435. }
  436. }
  437. }
  438. }
  439. },
  440. immediate: true
  441. }
  442. },
  443. methods: {
  444. getRowKeys(row) {
  445. return row.id
  446. },
  447. appletTypeChange(list, type) { // 小程序类型选择
  448. let appletList = type === 'alipayApplet' ? ['mp_ali_appid', 'mp_ali_app_path'] : ['appid', 'app_path'];
  449. this.appletList = list.filter(item => appletList.includes(item.name));
  450. },
  451. appletInputLink(event, item) { // 小程序输入框链接获取
  452. let wechatApplet = ['app_path', 'appid']; // 微信小程序链接
  453. let alipayApplet = ['mp_ali_app_path', 'mp_ali_appid']; // 支付宝小程序链接
  454. let appletData = []; // 小程序回显
  455. if (wechatApplet.includes(item.name)) { // 微信小程序
  456. appletData = this.appletList.filter(item => item.name === 'app_path')[0];
  457. }
  458. if (alipayApplet.includes(item.name)) { // 支付宝小程序
  459. appletData = this.appletList.filter(item => item.name === 'mp_ali_app_path')[0];
  460. }
  461. this.ruturn_value = [{
  462. title: appletData.name,
  463. open_type: this.appletChangeType,
  464. navigate: 'navigateTo',
  465. route: appletData.route,
  466. params: this.appletList ?? null,
  467. }];
  468. },
  469. otherInputLink(event, item, linkList = []) { // 其他插件中除小程序的输入框链接获取
  470. let wechatVideo = ['jumpType', 'finderUserName', 'feedId']; // 微信视频
  471. if (wechatVideo.includes(item.name)) {
  472. let route_path = linkList.filter(item => item.name === 'finderUserName')[0].route;
  473. this.ruturn_value = [{
  474. title: item.name,
  475. open_type: item.open_type,
  476. navigate: 'navigateTo',
  477. route: route_path,
  478. params: linkList ?? null,
  479. }];
  480. } else {
  481. this.ruturn_value = [{
  482. title: item.name,
  483. open_type: item.open_type,
  484. navigate: 'navigateTo',
  485. route: event,
  486. params: item ?? null,
  487. }];
  488. }
  489. },
  490. liActive(data, tabsName) { // li点击处理
  491. console.log('data',data,tabsName);
  492. var params = [data.id, data.name, data.is_list, tabsName];
  493. this.triggerLoadBox(params);
  494. },
  495. tabsClick(tab) { // tabs切换
  496. var li = $("#pane-" + tab.name + " .module-box-li li").eq(0);
  497. $(".left-li").removeClass("active");
  498. if (li.length == 0) return; // 没有数据不继续走下去
  499. var params = li[0].dataset.arr.split(','); // 数组顺序:id,name,is_list,tabs切换name
  500. params.push(tab.name);
  501. this.triggerLoadBox(params);
  502. },
  503. triggerLoadBox(params) { // 右侧框展开处理
  504. if (this.pickType.includes(params[1])) {
  505. this.inPickType = 1;
  506. } else {
  507. this.inPickType = 0;
  508. }
  509. this.otherId = params[3] == 'other' ? params[0] : -1;
  510. if (params[3] === 'other' && params[1] === 'applet_link') {
  511. this.appletTypeChange(this.link[params[0]]);
  512. }
  513. this.keyword = null;
  514. // 添加active处理
  515. $(".left-li").removeClass("active");
  516. $(".left-li-" + params[0]).addClass("active");
  517. // 隐藏列表框处理
  518. this.childrenBoxShow = params[0];
  519. // 判断加载列表内容
  520. if (params[2] == 1 && !$(".children-box-" + params[0]).hasClass('active')) {
  521. this.page = 1;
  522. this.activeType = params[1];
  523. this.loadBoxData(params[1]);
  524. }
  525. },
  526. pagination(currentPage) {
  527. let self = this;
  528. self.page = currentPage;
  529. self.loadBoxData(this.activeType);
  530. },
  531. loadBoxData(type) {
  532. var self = this;
  533. this.boxListLoading = true;
  534. let params = Object.assign(self.parameter, {
  535. r: this.is_store_route ? 'store/store-steward/link/get-pick-list' : 'mall/link/get-pick-list',
  536. type: type,
  537. keyword: this.keyword,
  538. page: self.page,
  539. level: this.cateValue,
  540. })
  541. if(this.isShowGoodsCateSelect === false){
  542. params.level = "1"
  543. }
  544. request({
  545. params: params,
  546. method: 'get',
  547. }).then(e => {
  548. this.boxListLoading = false;
  549. if (e.data.code === 0) {
  550. if (type == 'consumer_card') {
  551. self.boxList = e.data.data.list
  552. self.route = e.data.data.route;
  553. }else if(type == 'diy_template'){
  554. self.boxList = e.data.data.list
  555. self.route = e.data.data.route;
  556. }else{
  557. self.boxList = e.data.data.list.list;
  558. self.route = e.data.data.route;
  559. self.pageCount = e.data.data.list.page_count;
  560. }
  561. if (self.route.indexOf('/plugins/SmartForm/SmartForm') != -1) {
  562. // 只能表单选择链接
  563. self.boxDataType = 'SmartForm';
  564. }
  565. if (self.route.indexOf('/plugins2/merchantVoucher/activeCoupon') != -1) {
  566. // 只能表单选择链接
  567. self.boxDataType = 'AlipayMchCoupon';
  568. }
  569. this.getTableDefaultSelectList();
  570. } else {
  571. self.$message.error(e.data.msg);
  572. }
  573. }).catch(e => {});
  574. },
  575. handleChange(val) {
  576. console.log('handleChange',val);
  577. val.open_type = 'page';
  578. if (!isEmpty(val.more_params)) {
  579. val.route = val.route ? val.route + val.more_params : this.route + val.more_params;
  580. } else {
  581. val.route = val.route ? val.route + '?id=' + val.id : this.route + val.id;
  582. }
  583. if (val.route.indexOf('/plugins/LuckyGroup/productDetail') != -1) {
  584. val.route = val.route + '&activity_id=' + val.activity_id;
  585. }
  586. // 门店商品详情特殊处理
  587. if (val.route.indexOf('/plugins2/Store/store/storeDetail') != -1) {
  588. val.route = val.route + '&store_id=' + val.store_id
  589. }
  590. this.ruturn_value = [{
  591. title: val.title,
  592. open_type: val.open_type,
  593. navigate: 'navigateTo',
  594. route: val.route,
  595. params: val ? val : null,
  596. }];
  597. },
  598. dialogOpened() {
  599. this.currentCheckedItem = {};
  600. this.checkedList = [];
  601. this.checkedCities = [];
  602. this.return_value = []
  603. if (this.options.length == 0) {
  604. this.loadList({})
  605. }
  606. // 获取默认选中列表
  607. this.getTableDefaultSelectList();
  608. },
  609. // 默认选中列表
  610. getTableDefaultSelectList() {
  611. let self = this;
  612. self.$nextTick(() => {
  613. self.defaultSelectList.forEach(id => {
  614. const item = self.boxList.find(item => {
  615. return item.id === id; // 如需其他对比参数 - 自行更改对比参数
  616. })
  617. if (item) {
  618. self.$refs.multipleGoodsTable[0].toggleRowSelection(item);
  619. }
  620. });
  621. })
  622. },
  623. searchForm() {
  624. this.loadBoxData(this.activeType);
  625. },
  626. loadList() {
  627. this.loading = true;
  628. const params = {
  629. r: this.is_store_route ? 'store/store-steward/link/get-link' : 'mall/link/get-link',
  630. type: this.type
  631. };
  632. if (this.mallId) {
  633. params.mall_id = this.mallId;
  634. }
  635. request({
  636. params: params,
  637. method: 'post',
  638. }).then(e => {
  639. if (e.data.code === 0) {
  640. this.options = this.filterArr(e.data.data.menu)
  641. console.log(this.options);
  642. // 处理特殊过滤展示
  643. let score_game_menu = e.data.data.menu.filter(item => item.name === 'score_game')
  644. console.log('score_game_menu',score_game_menu);
  645. if (this.isDiyMenu && score_game_menu.length > 0) {
  646. score_game_menu.forEach(item => {
  647. item.children = item.children.filter(child => child.name === 'score_secondary_card');
  648. });
  649. }
  650. if(score_game_menu.length > 0){
  651. this.options.push(...score_game_menu)
  652. }
  653. this.link = e.data.data.link_arr;
  654. this.ruleForm = JSON.parse(JSON.stringify(e.data.data.link_arr));
  655. this.childrenBoxShow = this.options[0].children[0].id; // 初始化右边第一个页面
  656. this.activeName = this.options[0].name;
  657. this.getOhterList(this.activeName) // 需要初始二次请求的类型
  658. this.loading = false;
  659. } else {
  660. this.$message.error(e.data.msg);
  661. this.dialogFormVisible = false;
  662. }
  663. }).catch();
  664. },
  665. filterArr(target) {
  666. let handleArr = this.deepClone(target)
  667. let result = target.filter(item => {
  668. return this.defaultTabs.some(tag => {
  669. if (typeof tag === "string") { // 字符串类型
  670. return tag === item.name
  671. } else if (typeof tag === "object") { // 对象类型
  672. return tag.name === item.name
  673. } else { // 其他类型
  674. console.log("暂不支持该类型");
  675. return true
  676. }
  677. })
  678. }).map((item) => {
  679. if (item.children && item.children.length) {
  680. // 做二级侧边栏得处理
  681. item.children = item.children.filter(child => {
  682. return this.defaultTabs.some(tag => {
  683. if (typeof tag === "string") { // 字符串类型
  684. return true
  685. } else if (typeof tag === "object") { // 对象类型
  686. if (tag.children && tag.children.length) {
  687. return tag.children.indexOf(child.name) !== -1
  688. } else if (item.name === tag.name) {
  689. // 不填children直接全部展示
  690. return true
  691. } else {
  692. // 进入下一个判断
  693. return false
  694. }
  695. } else { // 其他类型
  696. console.log("暂不支持该类型");
  697. return false
  698. }
  699. })
  700. })
  701. }
  702. return item
  703. })
  704. return result
  705. },
  706. getOhterList(type) {
  707. const value = {
  708. goods: () => {
  709. this.liActive(this.options[0].children[0], 'goods')
  710. },
  711. marketing: () => {
  712. this.liActive(this.options[0].children[0], 'marketing')
  713. },
  714. addons: () => {
  715. this.liActive(this.options[0].children[0], 'addons')
  716. }
  717. }
  718. const cb = value[type]
  719. cb && cb()
  720. },
  721. jumpTypeChange(val, item) {
  722. console.log('跳转类型改变', val)
  723. item.open_type = val
  724. },
  725. confirm() {
  726. let self = this;
  727. // 其他获取返回值
  728. if (this.otherId != -1) {
  729. var otherInfo = this.link[this.otherId];
  730. var params = {};
  731. var open_type = '';
  732. otherInfo.forEach(function(item) {
  733. open_type = item.open_type;
  734. params[item.name] = item.route;
  735. });
  736. params['open_type'] = open_type;
  737. self.ruturn_value = [{
  738. title: '',
  739. open_type: open_type,
  740. navigate: 'navigateTo',
  741. route: '',
  742. params: params ? params : null
  743. }];
  744. }
  745. for (let i = 0; i < self.ruturn_value.length; i++) {
  746. if (self.ruturn_value[i]['params'] && self.ruturn_value[i]['params']['note_type'] === 2) {
  747. let videoStr = '/plugins/operating_note/video/index?content_id=';
  748. let id = self.ruturn_value[i]['params']['route'].split('id=')[1];
  749. self.ruturn_value[i]['params']['route'] = videoStr + id;
  750. }
  751. }
  752. self.$emit('selected', self.ruturn_value);
  753. self.dialogFormVisible = false;
  754. },
  755. selectBtn(item) {
  756. this.ruturn_value = [{
  757. title: item.title,
  758. open_type: item.open_type,
  759. navigate: 'navigateTo',
  760. route: item.route,
  761. params: item ? item : null,
  762. }];
  763. },
  764. closeDialog() {
  765. if (!isEmpty(this.$refs.multipleGoodsTable)) {
  766. this.$refs.multipleGoodsTable[0].clearSelection(); // 清空选择
  767. }
  768. this.dialogFormVisible = false;
  769. this.$emit("close", this.dialogFormVisible);
  770. },
  771. showPop() {
  772. this.dialogFormVisible = true;
  773. },
  774. handleSelectionChange(val) { // 多选商品
  775. console.log('val',val);
  776. let self = this;
  777. if (self.boxDataType == 'SmartForm' || self.boxDataType == 'AlipayMchCoupon') {
  778. if (val.length) {
  779. if (this.ruturn_value.length >= 1 || val.length > 1) {
  780. this.$message.error('最多只能选一个')
  781. this.ruturn_value = []
  782. if (!isEmpty(this.$refs.multipleGoodsTable)) {
  783. this.$refs.multipleGoodsTable[0].clearSelection(); // 清空选择
  784. }
  785. } else {
  786. this.ruturn_value = val
  787. }
  788. }
  789. } else {
  790. var temp = [];
  791. if (self.activeType == 'multi_goods_cate') {
  792. self.selectedRows = val
  793. if (val.length > 0) {
  794. let open_type = 'page'
  795. let route = self.route
  796. let title = val[0].title
  797. let navigate = 'navigateTo'
  798. let ids = ''
  799. val.forEach(function(item) {
  800. ids += item.id + ','
  801. })
  802. ids = ids.replace(/(^,)|(,*$)/g, '')
  803. route += ids
  804. temp.push({
  805. title,
  806. open_type,
  807. navigate,
  808. route,
  809. params: {
  810. title,
  811. open_type,
  812. navigate,
  813. route
  814. },
  815. })
  816. self.ruturn_value = temp
  817. console.log('self.ruturn_value', self.ruturn_value)
  818. } else {
  819. self.ruturn_value = [{
  820. title: '',
  821. open_type: 'page',
  822. navigate: 'navigateTo',
  823. route: '',
  824. params: null
  825. }]
  826. }
  827. } else {
  828. val.forEach(function(item) {
  829. item.open_type = 'page';
  830. item.route = self.route + item.id;
  831. temp.push({
  832. title: item.title,
  833. open_type: item.route,
  834. navigate: 'navigateTo',
  835. route: item.route,
  836. params: item ? item : null,
  837. });
  838. });
  839. self.ruturn_value = temp;
  840. console.log(self.ruturn_value);
  841. }
  842. }
  843. },
  844. deepClone(obj) {
  845. var o, i, j, k;
  846. if (typeof(obj) != "object" || obj === null) return obj;
  847. if (obj instanceof(Array)) {
  848. o = [];
  849. i = 0;
  850. j = obj.length;
  851. for (; i < j; i++) {
  852. if (typeof(obj[i]) == "object" && obj[i] != null) {
  853. o[i] = arguments.callee(obj[i]);
  854. } else {
  855. o[i] = obj[i];
  856. }
  857. }
  858. } else {
  859. o = {};
  860. for (i in obj) {
  861. if (typeof(obj[i]) == "object" && obj[i] != null) {
  862. o[i] = arguments.callee(obj[i]);
  863. } else {
  864. o[i] = obj[i];
  865. }
  866. }
  867. }
  868. return o;
  869. },
  870. // js过滤
  871. searchByType(name) {
  872. // 存储子级
  873. let childrenIds = []
  874. // 找到传过来的name下面的子级
  875. for (const top of this.options) {
  876. if (top.length === 0) {
  877. continue
  878. }
  879. for (const top2 of top.children) {
  880. if (top.length === 0) {
  881. continue
  882. }
  883. if (top2.name === name) {
  884. childrenIds = top2.children.map(item => item.id)
  885. break
  886. }
  887. }
  888. }
  889. if (childrenIds.length === 0) {
  890. return
  891. }
  892. if (this.searchKeyword === null || this.searchKeyword.trim() === '') {
  893. for (const childrenId of childrenIds) {
  894. if (this.link[childrenId] === undefined) {
  895. continue
  896. }
  897. this.link[childrenId] = JSON.parse(JSON.stringify(this.ruleForm[childrenId]))
  898. }
  899. return
  900. }
  901. // 备份
  902. for (const childrenId of childrenIds) {
  903. if (this.link[childrenId] === undefined) {
  904. continue
  905. }
  906. let copyArr = JSON.parse(JSON.stringify(this.ruleForm[childrenId]))
  907. this.link[childrenId] = copyArr.filter(item =>
  908. item.title.toLowerCase().includes(this.searchKeyword.toLowerCase())
  909. )
  910. }
  911. }
  912. },
  913. });
  914. </script>