index.vue 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099
  1. <template>
  2. <div class="app-container" ref='appFull' style="background: #fff;">
  3. <el-form :model="queryParams" ref="queryParams" v-show="showSearch" :inline="true">
  4. <el-form-item>
  5. <el-select v-model="queryParams.userId" size="small" placeholder="选择用户" filterable style="width: 140px" clearable>
  6. <el-option v-for="item in userAll" :key="item.id" :label="item.nickName" :value="item.id" />
  7. </el-select>
  8. </el-form-item>
  9. <el-form-item>
  10. <el-select v-model="queryParams.resourceTag" size="small" :disabled="!queryParams.userId" placeholder="角色标签" filterable style="width: 100px" clearable>
  11. <el-option v-for="(item, index) in tagAll" :key="index" :label="item.resourceTag" :value="item.resourceTag" />
  12. </el-select>
  13. </el-form-item>
  14. <el-form-item label="" prop="resourceName">
  15. <el-input v-model="queryParams.resourceName" placeholder="请输入资源名称" clearable size="small" style="width: 150px" @keyup.enter.native="handleQuery" />
  16. </el-form-item>
  17. <el-form-item label="" prop="resourceKey">
  18. <el-input v-model="queryParams.resourceKey" placeholder="请输入资源标识" clearable size="small" style="width: 150px" @keyup.enter.native="handleQuery" />
  19. </el-form-item>
  20. <el-form-item label="" prop="resourceGroupId">
  21. <el-select v-model="queryParams.resourceGroupId" placeholder="资源分组" clearable filterable style="width: 140px" size="small">
  22. <el-option v-for="dict in groupingData" :key="dict.id" :label="dict.groupName" :value="dict.id" />
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item prop="resourceType">
  26. <el-select style="width: 140px" v-model="queryParams.resourceType" placeholder="资源类型" filterable clearable size="small">
  27. <el-option v-for="item in resourceTypes" :key="item.value" :label="item.label" :value="item.value"></el-option>
  28. </el-select>
  29. </el-form-item>
  30. <el-form-item prop="resourceType">
  31. <el-select v-model="queryParams.businessGroupId" size="small" placeholder="选择项目组" filterable style="width: 140px" clearable>
  32. <el-option v-for="item in teamsList" :key="item.id" :label="item.businessGroupName" :value="item.id" />
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item>
  36. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  37. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  38. </el-form-item>
  39. </el-form>
  40. <el-row :gutter="10" class="mb8">
  41. <el-col :span="1.5">
  42. <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd">新增资源</el-button>
  43. </el-col>
  44. <el-col :span="1.5">
  45. <el-button type="success" icon="el-icon-refresh" size="mini" @click="handleRefresh">刷新服务器缓存</el-button>
  46. </el-col>
  47. <el-col :span="1.5">
  48. <el-button type="danger" icon="el-icon-delete-solid" size="mini" :disabled="delIds.length == 0" @click="handleDel">删除</el-button>
  49. </el-col>
  50. <!-- <el-col :span="1.5">
  51. <el-button
  52. type="info"
  53. icon="el-icon-upload2"
  54. size="mini"
  55. @click="handleImport"
  56. >导入</el-button>
  57. </el-col> -->
  58. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  59. </el-row>
  60. <el-table
  61. :data="accountList"
  62. size="mini"
  63. v-loading="loading"
  64. @selection-change="handleSelectionChange"
  65. >
  66. <el-table-column type="selection" width="50" align="center" fixed="left"/>
  67. <el-table-column label="资源名称" prop="resourceName" :show-overflow-tooltip="true" width="120" fixed="left"/>
  68. <el-table-column label="资源标识" prop="resourceKey" :show-overflow-tooltip="true" width="150" fixed="left"/>
  69. <el-table-column label="项目组" prop="businessGroupInfo" width="80" :show-overflow-tooltip="true" align="center">
  70. <template slot-scope="scope" v-if="scope.row.businessGroupInfo">
  71. <span>{{scope.row.businessGroupInfo.businessGroupName}}</span>
  72. </template>
  73. </el-table-column>
  74. <el-table-column prop="operUserInfo" width="100" align="center" label="运营">
  75. <template slot-scope="scope" v-if="scope.row.operUserInfo">
  76. <el-popover :width="200" trigger="hover" placement="top" :title="scope.row.operUserInfo.nickname">
  77. <div style="color: rgb(136, 136, 136); font-size: 13px">
  78. 电话:{{ scope.row.operUserInfo.phone }}
  79. </div>
  80. <div slot="reference">{{ scope.row.operUserInfo.nickname }}</div>
  81. </el-popover>
  82. </template>
  83. </el-table-column>
  84. <el-table-column prop="putUserInfo" width="100" align="center" label="投手">
  85. <template slot-scope="scope" v-if="scope.row.putUserInfo">
  86. <el-popover :width="200" trigger="hover" placement="top" :title="scope.row.putUserInfo.nickname">
  87. <div style="color: rgb(136, 136, 136); font-size: 13px">
  88. 电话:{{ scope.row.putUserInfo.phone }}
  89. </div>
  90. <div slot="reference">{{ scope.row.putUserInfo.nickname }}</div>
  91. </el-popover>
  92. </template>
  93. </el-table-column>
  94. <!-- <el-table-column prop="userRelationList" width="100" align="center" label="审查">
  95. <template slot-scope="scope" v-if="scope.row.userRelationList">
  96. <el-popover :width="200" trigger="hover" placement="top" :title="scope.row.userRelationList.nickName">
  97. <div style="color: rgb(136, 136, 136); font-size: 13px">
  98. 电话:{{ scope.row.userRelationList.phone }}
  99. </div>
  100. <div slot="reference">{{ scope.row.userRelationList.nickName }}</div>
  101. </el-popover>
  102. </template>
  103. </el-table-column> -->
  104. <el-table-column label="资源类型" prop="resourceType" align="center" width="150">
  105. <template slot-scope="scope">
  106. <el-tag size="mini" :type="resourceTypes[0].type" v-if="scope.row.resourceType === 0">{{resourceTypes[0].label}}</el-tag>
  107. <el-tag size="mini" :type="resourceTypes[1].type" v-if="scope.row.resourceType === 1">{{resourceTypes[1].label}}</el-tag>
  108. <el-tag size="mini" :type="resourceTypes[2].type" v-if="scope.row.resourceType === 3">{{resourceTypes[2].label}}</el-tag>
  109. <el-tag size="mini" :type="resourceTypes[3].type" v-if="scope.row.resourceType === 10">{{resourceTypes[3].label}}</el-tag>
  110. <el-tag size="mini" :type="resourceTypes[4].type" v-if="scope.row.resourceType === 20">{{resourceTypes[4].label}}</el-tag>
  111. </template>
  112. </el-table-column>
  113. <el-table-column label="所属分组" prop="groupInfo" width="120" align="center">
  114. <template slot-scope="scope">
  115. <span v-if="scope.row.groupInfo">{{scope.row.groupInfo.groupName}}</span>
  116. <span v-else></span>
  117. </template>
  118. </el-table-column>
  119. <el-table-column label="投放状态" prop="putStatus" width="80" align="center">
  120. <template slot-scope="scope">
  121. <el-tag type="warning" v-if="scope.row.putStatus === 'wait'">待投放</el-tag>
  122. <el-tag type="success" v-else-if="scope.row.putStatus === 'ing'">投放中</el-tag>
  123. <el-tag type="info" v-else-if="scope.row.putStatus === 'stop'">停投</el-tag>
  124. <el-tag type="danger" v-else-if="scope.row.putStatus === 'destroy'">账号已注销</el-tag>
  125. <div v-else>--</div>
  126. </template>
  127. </el-table-column>
  128. <el-table-column label="投放渠道" prop="putChannel" align="center" width="80" />
  129. <el-table-column label="期数" prop="periodInfo" width="100" align="center">
  130. <template slot-scope="scope" v-if="scope.row.periodInfo">
  131. <div>
  132. {{ scope.row.periodInfo.period }}
  133. </div>
  134. </template>
  135. </el-table-column>
  136. <el-table-column label="当前书籍" prop="bookInfo" width="120" align="center">
  137. <template slot-scope="scope" v-if="scope.row.bookInfo">
  138. <el-popover width="200" trigger="hover" placement="top" :title="scope.row.bookInfo.bookName">
  139. <div style="color: rgb(136, 136, 136); font-size: 13px">
  140. <strong>来源:</strong>
  141. <span>{{ scope.row.bookInfo.source }}-{{ scope.row.bookInfo.author }}</span>
  142. </div>
  143. <div style="color: rgb(136, 136, 136); font-size: 13px">
  144. <strong>信息:</strong>
  145. <span>{{ scope.row.bookInfo.protagonist }}-{{ scope.row.bookInfo.channel }}</span>
  146. </div>
  147. <div slot="reference">{{ scope.row.bookInfo.bookName }}</div>
  148. </el-popover>
  149. </template>
  150. </el-table-column>
  151. <el-table-column prop="platformInfo" label="书城信息" width="100" align="center">
  152. <template slot-scope="scope" v-if="scope.row.platformInfo">
  153. <div>
  154. {{ scope.row.platformInfo.platformName }}
  155. </div>
  156. </template>
  157. </el-table-column>
  158. <el-table-column prop="rechargeTemplate" label="充值模板" width="100" align="center">
  159. <template slot-scope="scope">
  160. <div>
  161. {{ scope.row.rechargeTemplate }}
  162. </div>
  163. </template>
  164. </el-table-column>
  165. <el-table-column label="账号" prop="platformAccountInfo" width="300">
  166. <template slot-scope="scope">
  167. <div v-if="scope.row.platformAccountInfo && scope.row.platformAccountInfo.account">
  168. <span style="color: rgb(136, 136, 136); font-size: 12px">
  169. <span>
  170. {{ scope.row.platformAccountInfo.account }}&nbsp;
  171. <!-- <i class="el-icon-document-copy copy" @click="Copy(scope.row.platformAccountInfo.account)"></i>
  172. {{ scope.row.platformAccountInfo.password }}&nbsp;
  173. <i class="el-icon-document-copy copy" @click="Copy(scope.row.platformAccountInfo.password)"></i> -->
  174. </span>
  175. </span>
  176. </div>
  177. </template>
  178. </el-table-column>
  179. <el-table-column label="创建时间" prop="createTime" width="135"/>
  180. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="120">
  181. <template slot-scope="scope">
  182. <!-- <div class="Space"></div> -->
  183. <el-popover placement="top" width="200" @hide="handlePullHide" trigger="click">
  184. <div>
  185. <el-row type="flex" justify="space-between" class="grouping">
  186. <span>移动至</span>
  187. <el-button
  188. size="mini"
  189. type="text"
  190. :icon="gVis ? 'el-icon-close' : 'el-icon-plus'"
  191. @click="handleGAdd"
  192. >{{gVis ? '取消' : '新增'}}</el-button>
  193. </el-row>
  194. <div v-show="gVis">
  195. <div class="Space"></div>
  196. <el-input placeholder="请输入内容" v-model="groupValue" class="input-with-select" size="mini">
  197. <el-button slot="append" type="primary" @click="handleAddGroup">添加</el-button>
  198. </el-input>
  199. </div>
  200. <ul class="groupingNames">
  201. <li v-for="gItem in groupingData" :key="gItem.id">
  202. <template v-if="!gItem.isUpdata">
  203. <div class="gnTxt" v-if="scope.row.groupInfo && scope.row.groupInfo.id == gItem.id">
  204. <span style="color: red">*</span>{{gItem.groupName}}
  205. </div>
  206. <div class="gnTxt" v-else>
  207. {{gItem.groupName}}
  208. </div>
  209. <div class="gnBts gnnone" v-if="!scope.row.groupInfo || scope.row.groupInfo.id != gItem.id" @click.stop.prevent="editAccountGroup(scope.row.id, gItem.id)">
  210. <el-row type="flex" justify="space-around" align="middle" class="bts">
  211. <el-button size="mini" type="text" icon="el-icon-edit" style="color: #409EFF" @click.stop="handleGUpdata(gItem.id)"></el-button>
  212. <el-popconfirm title="确定删除该分组?" @confirm="handleGroupDel(gItem.id)">
  213. <el-button slot="reference" size="mini" type="text" icon="el-icon-delete" style="color: red" @click.stop=""></el-button>
  214. </el-popconfirm>
  215. </el-row>
  216. </div>
  217. </template>
  218. <template v-else>
  219. <el-input placeholder="请输入内容" v-model="newGroupName" class="input-with-select" size="mini">
  220. <el-button slot="append" type="primary" @click="handleGroupEdit(gItem.id, )">修改</el-button>
  221. </el-input>
  222. </template>
  223. </li>
  224. </ul>
  225. </div>
  226. <el-button size="mini" type="text" icon="el-icon-folder-opened" slot="reference" >分组</el-button>
  227. </el-popover>
  228. <el-dropdown trigger="click" size="mini">
  229. <span class="el-dropdown-link">
  230. 更多<i class="el-icon-arrow-down el-icon--right"></i>
  231. </span>
  232. <el-dropdown-menu slot="dropdown">
  233. <el-dropdown-item><change-record v-model="scope.row" :periodList="periodList" :bookCity="bookCity" :bookList="bookList" :teamsList="teamsList" :userAll="userAll" type="acc"/></el-dropdown-item>
  234. <el-dropdown-item><div class="dropdownItem" @click="handleEdit(scope.row)"><i class="el-icon-edit"></i>编辑</div></el-dropdown-item>
  235. <el-dropdown-item><div class="dropdownItem" @click="handleState(scope.row)"><i class="el-icon-s-check"></i> 指派</div></el-dropdown-item>
  236. <el-dropdown-item><cut-book v-model="scope.row" :periodList="periodList" :bookCity="bookCity" :bookList="bookList" @change="getList" :teamsList="teamsList"/></el-dropdown-item>
  237. </el-dropdown-menu>
  238. </el-dropdown>
  239. </template>
  240. </el-table-column>
  241. </el-table>
  242. <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList"/>
  243. <!-- 新增 编辑弹窗 -->
  244. <el-dialog
  245. :title="isAdd ? '新增资源库' : '编辑资源库'"
  246. :visible.sync="openEdit"
  247. :width="isAdd ? '500px' : '640px'"
  248. append-to-body
  249. @close="addClose"
  250. >
  251. <el-form :model="queryPlatform" :rules="rules" ref="platForm" label-position="top" :inline="true">
  252. <el-form-item label="开始时间" prop="beginTime" style="width: 100%">
  253. <el-date-picker v-model="queryPlatform.beginTime" size="small" format="yyyy-MM-dd" value-format="yyyy-MM-dd" type="date" placeholder="选择开始时间" />
  254. </el-form-item>
  255. <el-form-item label="资源名称" prop="resourceName" style="width: 140px">
  256. <el-input v-model="queryPlatform.resourceName" placeholder="输入资源名称"/>
  257. </el-form-item>
  258. <el-form-item label="资源标识" prop="resourceKey" style="width: 140px">
  259. <el-input v-model="queryPlatform.resourceKey" placeholder="输入资源标识"/>
  260. </el-form-item>
  261. <el-form-item prop="resourceType" label="资源类型" style="width: 140px">
  262. <el-select v-model="queryPlatform.resourceType" placeholder="资源类型" filterable clearable size="small">
  263. <el-option
  264. v-for="item in resourceTypes"
  265. :key="item.value"
  266. :label="item.label"
  267. :value="item.value">
  268. </el-option>
  269. </el-select>
  270. </el-form-item>
  271. <el-form-item label="资源分组" prop="resourceGroupId" style="width: 140px;">
  272. <el-select v-model="queryPlatform.resourceGroupId" placeholder="资源分组" clearable filterable size="small">
  273. <el-option v-for="dict in groupingData" :key="dict.id" :label="dict.groupName" :value="dict.id"/>
  274. </el-select>
  275. </el-form-item>
  276. <el-form-item label="项目组" prop="businessGroupId" v-if="isAdd">
  277. <el-select v-model="queryPlatform.businessGroupId" size="small" placeholder="选择项目组" filterable style="width: 140px" clearable>
  278. <el-option v-for="item in teamsList" :key="item.id" :label="item.businessGroupName" :value="item.id" />
  279. </el-select>
  280. </el-form-item>
  281. <el-form-item label="期数" prop="periodId" v-if="isAdd">
  282. <el-select v-model="queryPlatform.periodId" size="small" placeholder="选择期数" filterable style="width: 140px" clearable>
  283. <el-option v-for="item in periodList" :key="item.id" :label="item.period" :value="item.id" />
  284. </el-select>
  285. </el-form-item>
  286. <el-form-item label="书城" prop="platformId" v-if="isAdd">
  287. <el-select v-model="queryPlatform.platformId" @change="selectZh" size="small" placeholder="选择书城" filterable style="width: 140px" clearable>
  288. <el-option v-for="item in bookCity" :key="item.id" :label="item.platformName" :value="item.id" />
  289. </el-select>
  290. </el-form-item>
  291. <el-form-item label="账号" prop="platformAccountId" v-if="isAdd">
  292. <el-select v-model="queryPlatform.platformAccountId" :disabled="!queryPlatform.platformId" size="small" placeholder="选择账号" filterable style="width: 140px" clearable>
  293. <el-option v-for="item in accList" :key="item.id" :label="item.account" :value="item.id" />
  294. </el-select>
  295. </el-form-item>
  296. <el-form-item label="书" prop="bookId" v-if="isAdd">
  297. <el-select v-model="queryPlatform.bookId" size="small" placeholder="选择书" filterable style="width: 140px" clearable>
  298. <el-option v-for="item in bookList" :key="item.id" :label="item.bookName" :value="item.id" />
  299. </el-select>
  300. </el-form-item>
  301. <el-form-item label="投放状态" prop="putStatus" v-if="isAdd">
  302. <el-select v-model="queryPlatform.putStatus" size="small" placeholder="选择投放状态" filterable style="width: 140px" clearable>
  303. <el-option label="待投放" value="wait" />
  304. <el-option label="投放中" value="ing" />
  305. <el-option label="停投" value="stop" />
  306. <el-option label="账号已注销" value="destroy" />
  307. </el-select>
  308. </el-form-item>
  309. <el-form-item label="投放渠道" prop="putChannel" v-if="isAdd">
  310. <el-select v-model="queryPlatform.putChannel" size="small" placeholder="选择投放渠道" filterable style="width: 140px" clearable>
  311. <el-option label="MP" value="MP" />
  312. <el-option label="GDT" value="GDT" />
  313. <el-option label="头条" value="头条" />
  314. <el-option label="企微" value="企微" />
  315. </el-select>
  316. </el-form-item>
  317. <el-form-item label="充值模板" prop="rechargeTemplate" v-if="isAdd">
  318. <el-input v-model="queryPlatform.rechargeTemplate" size="small" style="width: 140px" placeholder="输入充值模板" />
  319. </el-form-item>
  320. </el-form>
  321. <span slot="footer" class="dialog-footer">
  322. <el-button @click="openEdit = false">取 消</el-button>
  323. <el-button type="primary" @click="submit('platForm')">确 定</el-button>
  324. </span>
  325. </el-dialog>
  326. <!-- 指派 -->
  327. <el-dialog
  328. title="指派用户"
  329. :visible.sync="openEditType"
  330. width="450px"
  331. append-to-body
  332. >
  333. <el-form label-width="80px" label-position="top" ref="platFormTimeType" :model="timeData" :rules="rulesTimeType">
  334. <el-form-item label="开始时间(修改运营和投手后必选)" prop="beginTime">
  335. <el-date-picker
  336. v-model="timeData.beginTime"
  337. type="date"
  338. format="yyyy-MM-dd"
  339. value-format="yyyy-MM-dd"
  340. placeholder="选择开始时间">
  341. </el-date-picker>
  342. </el-form-item>
  343. </el-form>
  344. <el-form :model="item" :rules="rulesType" ref="platFormType" label-width="80px" label-position="top" v-for="(item, index) in queryPlatformType" :key="index">
  345. <el-row :gutter="20">
  346. <el-col :span="14">
  347. <el-form-item label="用户" prop="userId" >
  348. <el-select v-model="item.userId" placeholder="请选择" filterable style="width: 100%" clearable>
  349. <el-option
  350. v-for="item in userAll"
  351. :key="item.id"
  352. :label="item.nickName"
  353. :value="item.id">
  354. </el-option>
  355. </el-select>
  356. </el-form-item>
  357. </el-col>
  358. <el-col :span="6">
  359. <el-form-item label="角色标签" prop="resourceTag">
  360. <el-select v-model="item.resourceTag" placeholder="角色标签" filterable clearable>
  361. <el-option
  362. v-for="(item1, index1) in tagAll"
  363. :key="index1"
  364. :label="item1.resourceTag"
  365. :value="item1.resourceTag">
  366. </el-option>
  367. </el-select>
  368. </el-form-item>
  369. </el-col>
  370. <!-- <el-col :span="6">
  371. <el-form-item label="开始时间" prop="beginTime">
  372. <el-date-picker
  373. style="width: 100%"
  374. v-model="item.beginTime"
  375. type="date"
  376. format="yyyy-MM-dd"
  377. value-format="yyyy-MM-dd HH:mm:ss"
  378. placeholder="选择开始时间">
  379. </el-date-picker>
  380. </el-form-item>
  381. </el-col>
  382. <el-col :span="6">
  383. <el-form-item label="结束时间" prop="endTime">
  384. <el-date-picker
  385. style="width: 100%"
  386. v-model="item.endTime"
  387. type="date"
  388. value-format="yyyy-MM-dd HH:mm:ss"
  389. placeholder="选择结束时间">
  390. </el-date-picker>
  391. </el-form-item>
  392. </el-col> -->
  393. <el-col :span="2">
  394. <div style="margin-top: 42px">
  395. <el-button @click.prevent="removeResource(index)" type="text" icon="el-icon-delete" style="color: red; margin-left: 10px"></el-button>
  396. </div>
  397. </el-col>
  398. </el-row>
  399. </el-form>
  400. <el-button type="text" icon="el-icon-plus" @click="addResource">新增用户</el-button>
  401. <span slot="footer" class="dialog-footer">
  402. <el-button @click="queryPlatformType = [];openEditType = false">取 消</el-button>
  403. <el-button type="primary" @click="submitState('platFormType')">确 定</el-button>
  404. </span>
  405. </el-dialog>
  406. <!-- 公众号导入对话框 -->
  407. <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  408. <el-upload
  409. ref="upload"
  410. :limit="1"
  411. accept=".xlsx, .xls"
  412. :headers="upload.headers"
  413. :action="upload.url + '?updateSupport=' + upload.updateSupport"
  414. :disabled="upload.isUploading"
  415. :on-progress="handleFileUploadProgress"
  416. :on-success="handleFileSuccess"
  417. :auto-upload="false"
  418. drag
  419. >
  420. <i class="el-icon-upload"></i>
  421. <div class="el-upload__text">
  422. 将文件拖到此处,或
  423. <em>点击上传</em>
  424. </div>
  425. <!-- <div class="el-upload__tip" slot="tip">
  426. <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的公众号数据
  427. <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
  428. </div> -->
  429. <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
  430. </el-upload>
  431. <div slot="footer" class="dialog-footer">
  432. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  433. <el-button @click="upload.open = false">取 消</el-button>
  434. </div>
  435. </el-dialog>
  436. </div>
  437. </template>
  438. <script>
  439. import { getResourceList, addResource, delResource,
  440. editResource, addGroup, getGroupAllList, refreshCache,
  441. delGroup, editGroup, editAccountGroup, assignResourceUser, getRoleAll } from "@/api/accounts/account";
  442. import { allUser } from "@/api/system/user";
  443. import { getToken } from "@/utils/auth";
  444. import { Copy } from "@/utils";
  445. import { getBusinessGroupAll } from "@/api/admin/teams";
  446. import { getPeriodAll } from "@/api/accounts/period";
  447. import { getBookPlatInfoAll } from "@/api/accounts/bookCity";
  448. import { getBookAcc, getBookAll } from "@/api/system/books";
  449. import cutBook from './components/cutBook.vue'
  450. import changeRecord from './components/changeRecord.vue'
  451. export default {
  452. name: 'Account',
  453. components: { cutBook, changeRecord },
  454. data() {
  455. return {
  456. loading: false,
  457. upload: {
  458. // 是否显示弹出层(用户导入)
  459. open: false,
  460. // 弹出层标题(用户导入)
  461. title: "",
  462. // 是否禁用上传
  463. isUploading: false,
  464. // 是否更新已经存在的用户数据
  465. updateSupport: 0,
  466. // 设置上传的请求头部
  467. headers: { Authorization: "Bearer " + getToken() },
  468. // 上传的地址
  469. url: process.env.VUE_APP_BASE_API + "/system/mp/admin/importExcel"
  470. },
  471. groupValue: '',
  472. newGroupName: '',
  473. gVis: false, // 控制新增分组输入框
  474. queryParams: {
  475. pageNum: 1,
  476. pageSize: 10
  477. },
  478. showSearch: true,
  479. // 状态信息
  480. statusOptions: [
  481. {
  482. dictLabel: '待分配',
  483. dictValue: 0
  484. },
  485. {
  486. dictLabel: '投放中',
  487. dictValue: 1
  488. },
  489. {
  490. dictLabel: '停投',
  491. dictValue: 2
  492. },
  493. {
  494. dictLabel: '已注销',
  495. dictValue: 3
  496. }
  497. ],
  498. resourceTypes: [
  499. {label: '公众号', value: 0, type: 'success'},
  500. {label: '小程序', value: 1, type: 'danger'},
  501. {label: '企业微信', value: 3, type: 'info'},
  502. {label: '快应用', value: 10, type: 'warning'},
  503. {label: '头条账号', value: 20, type: ''}
  504. ],
  505. // 编辑弹窗
  506. openEdit: false,
  507. // 总条数
  508. total: 0,
  509. // 公众号表格信息
  510. accountList: [],
  511. // 分组数据
  512. groupingData: [],
  513. isAdd: true,
  514. queryPlatform: {},
  515. rules: {
  516. beginTime: [
  517. { required: true, message: '请输入开始时间', trigger: 'blur' }
  518. ],
  519. resourceName: [
  520. { required: true, message: '请输入资源名称', trigger: 'blur' }
  521. ],
  522. resourceKey: [
  523. { required: true, message: '请输入资源Key', trigger: 'blur' }
  524. ],
  525. resourceType: [
  526. { required: true, message: '请选择类型', trigger: 'blur' }
  527. ],
  528. putStatus: [
  529. { required: true, message: '请选择投放状态', trigger: 'blur' }
  530. ]
  531. },
  532. userAll: [], //所有用户
  533. openEditType: false, // 指派弹窗控制
  534. queryPlatformType: [],
  535. rulesType: {
  536. userId: [
  537. { required: true, message: '请选择用户', trigger: 'change' }
  538. ],
  539. resourceTag: [
  540. { required: true, message: '请选择角色标签', trigger: 'change' }
  541. ]
  542. },
  543. state: [
  544. {label: 1, value: '投放中'},
  545. {label: 2, value: '停投'},
  546. {label: 3, value: '已注销'}
  547. ],
  548. // 所有资源角色标签
  549. tagAll: [],
  550. resourceId: null,
  551. // 保存多选ID
  552. delIds: [],
  553. resourceData: {}, // 保存当前资源信息
  554. teamsList: [], // 项目组
  555. periodList: [], // 所有期数
  556. bookCity: [], // 所有书城
  557. bookList: [], // 所有书
  558. accList: [], // 所有账号
  559. timeData: {},
  560. rulesTimeType: {
  561. // beginTime: [
  562. // { required: true, message: '请选择开始时间', trigger: 'change' }
  563. // ],
  564. },
  565. }
  566. },
  567. mounted(){
  568. this.total = this.accountList.length
  569. window.addEventListener('storage', (e) => {
  570. if (e.key === 'code') {
  571. if (e.newValue === 'ok') {
  572. this.$router.go(0)
  573. this.msgSuccess("授权成功");
  574. localStorage.removeItem('code')
  575. } else {
  576. this.$message.error('授权失败');
  577. localStorage.removeItem('code')
  578. }
  579. }
  580. })
  581. },
  582. created() {
  583. this.getAll()
  584. this.getList()
  585. this.getGroupList()
  586. this.getCutXgData()
  587. },
  588. methods: {
  589. selectZh(e, id) {
  590. // 获取所有账号
  591. getBookAcc(e).then(res => {
  592. this.accList = res.data
  593. })
  594. },
  595. /** 新增编辑记录获取数据 */
  596. getCutXgData() {
  597. // 获取项目组
  598. getBusinessGroupAll().then(res => {
  599. this.teamsList = res.data
  600. })
  601. // 获取期数
  602. getPeriodAll().then(response => {
  603. this.periodList = response.data
  604. });
  605. // 获取所有书城
  606. getBookPlatInfoAll().then(res => {
  607. this.bookCity = res.data
  608. })
  609. // 获取所有书
  610. getBookAll().then(res => {
  611. this.bookList = res.data
  612. })
  613. },
  614. /** 新增用户 */
  615. addResource() {
  616. let oldData = JSON.parse(JSON.stringify(this.queryPlatformType))
  617. oldData.push({
  618. userId: null,
  619. resourceTag: null,
  620. beginTime: null,
  621. endTime: null
  622. })
  623. this.queryPlatformType = oldData
  624. },
  625. /** 删除用户 */
  626. removeResource(index) {
  627. this.queryPlatformType.splice(index, 1)
  628. },
  629. /** 刷新缓存 */
  630. handleRefresh() {
  631. refreshCache().then(res => {
  632. if(res.data) {
  633. this.msgSuccess('刷新成功');
  634. }
  635. })
  636. },
  637. /**图片返回失败 */
  638. avatarErr() {
  639. return true
  640. },
  641. /** 获取所有 */
  642. getAll() {
  643. // 所有用户
  644. allUser().then(response => {
  645. let data = response.data
  646. this.userAll = data.map((item) => {
  647. return { id: item.userId, nickName: item.nickname }
  648. })
  649. })
  650. // 获取所有角色
  651. getRoleAll().then(res => {
  652. this.tagAll = res.data
  653. })
  654. },
  655. /** 分组拉取 */
  656. handlePullHide() {
  657. this.gVis = false
  658. this.groupingData = this.groupingData.map((gitem)=>{
  659. return { ...gitem, isUpdata: false }
  660. })
  661. },
  662. /** 分组新增 */
  663. handleGAdd(){
  664. this.gVis = !this.gVis
  665. },
  666. /** 分组修改 */
  667. handleGUpdata(id){
  668. this.groupingData = this.groupingData.map((gitem)=>{
  669. if(id === gitem.id){
  670. this.newGroupName = gitem.groupName
  671. return { ...gitem, isUpdata: true }
  672. }else{
  673. return { ...gitem, isUpdata: false }
  674. }
  675. })
  676. },
  677. /** 编辑按钮方法 */
  678. handleEdit(value) {
  679. console.log(value)
  680. let { id, resourceKey, resourceName, bookId, rechargeTemplate, putChannel, putStatus, platformAccountId, platformId, resourceType, resourceGroupId, businessGroupId, periodId } = value
  681. this.$nextTick(() => {
  682. this.queryPlatform = Object.assign({}, {
  683. id,
  684. resourceKey,
  685. resourceName,
  686. resourceType,
  687. resourceGroupId,
  688. businessGroupId,
  689. periodId,
  690. platformId,
  691. platformAccountId,
  692. bookId,
  693. putStatus,
  694. putChannel,
  695. rechargeTemplate
  696. }) // 给表单赋值
  697. })
  698. this.isAdd = false
  699. this.openEdit = true
  700. },
  701. /** 查询公众号列表 */
  702. getList() {
  703. this.loading = true
  704. getResourceList(this.queryParams).then(response => {
  705. this.loading = false
  706. let data = response.data
  707. this.accountList = data.records
  708. this.total = data.total
  709. }).catch(() => this.loading = false)
  710. },
  711. /** 搜索 */
  712. handleQuery() {
  713. this.queryParams.pageNum = 1
  714. this.getList()
  715. },
  716. /** 状态修改 */
  717. handleState(value){
  718. if (value.userRelationList && value.userRelationList.length > 0) {
  719. this.queryPlatformType = value.userRelationList.map(item => {
  720. return {
  721. userId: item.userId,
  722. resourceTag: item.resourceTag,
  723. beginTime: item.beginTime,
  724. endTime: item.endTime
  725. }
  726. })
  727. } else {
  728. this.queryPlatformType = [{
  729. userId: null,
  730. resourceTag: null,
  731. beginTime: null,
  732. endTime: null
  733. }]
  734. }
  735. this.timeData = {}
  736. this.resourceId = value.id
  737. this.openEditType = true
  738. },
  739. /** 重置搜索条件 */
  740. resetQuery() {
  741. this.queryParams = {
  742. pageNum: 1,
  743. pageSize: 10
  744. }
  745. this.getList()
  746. },
  747. // 新增公众号
  748. handleAdd() {
  749. this.isAdd = true
  750. this.openEdit = true
  751. this.queryPlatform = {}
  752. },
  753. /** 新增 编辑 提交 */
  754. submit(formName) {
  755. this.$refs[formName].validate((valid) => {
  756. if (valid) {
  757. if(this.isAdd){
  758. addResource(this.queryPlatform).then(response => {
  759. if(response.data){
  760. this.msgSuccess("新增成功");
  761. this.resetForm("platForm");
  762. this.openEdit = false
  763. this.getList()
  764. }
  765. this.addClose()
  766. })
  767. }else{
  768. editResource(this.queryPlatform).then(response => {
  769. if(response.data){
  770. this.msgSuccess("修改成功");
  771. this.resetForm("platForm");
  772. this.openEdit = false
  773. this.getList()
  774. }
  775. this.addClose()
  776. })
  777. }
  778. } else {
  779. return false;
  780. }
  781. });
  782. },
  783. /** 状态提交 */
  784. submitState(formName) {
  785. this.$refs['platFormTimeType'].validate((valid) => {
  786. if (valid) {
  787. let state = this.$refs[formName].map(async item => {
  788. return await this.stateHandle(item)
  789. })
  790. Promise.all(state).then(res => {
  791. if(res.every(item => item)) {
  792. assignResourceUser({ resourceId: this.resourceId, beginTime: this.timeData.beginTime, relationList: this.queryPlatformType }).then(response => {
  793. if(response.data){
  794. this.msgSuccess("指派成功");
  795. // this.resetForm(formName);
  796. this.queryPlatformType = []
  797. this.timeData = {}
  798. this.openEditType = false
  799. this.getList()
  800. }
  801. })
  802. }
  803. })
  804. }
  805. })
  806. },
  807. stateHandle(ref) {
  808. return new Promise((resolve) => {
  809. ref.validate(valid => resolve(valid))
  810. })
  811. },
  812. /** 多选 */
  813. handleSelectionChange(selection) {
  814. this.delIds = selection.map((item) => item.id)
  815. },
  816. // 删除
  817. handleDel() {
  818. this.$confirm('确定删除?', '删除', {
  819. distinguishCancelAndClose: true,
  820. confirmButtonText: '确定',
  821. cancelButtonText: '取消'
  822. }).then(() => {
  823. delResource(this.delIds.toString()).then(res => {
  824. if(res.data) {
  825. this.msgSuccess('删除成功');
  826. this.getList()
  827. }
  828. })
  829. })
  830. },
  831. /** 时间转换 */
  832. parserTime(time){
  833. const d = new Date(time)
  834. const resDate = d.getFullYear() + '-' + this.p((d.getMonth() + 1)) + '-' + this.p(d.getDate())
  835. return resDate
  836. },
  837. p(s) {
  838. return s < 10 ? '0' + s : s
  839. },
  840. /** 关闭弹窗调用 */
  841. addClose() {
  842. if(!this.isAdd){
  843. this.queryPlatform = {}
  844. }
  845. },
  846. /** 分组新政 */
  847. handleAddGroup() {
  848. if(this.groupValue === ''){
  849. this.$message.error('请输入分组');
  850. return
  851. }
  852. addGroup({groupName: this.groupValue}).then(response => {
  853. if(response.data){
  854. this.getGroupList()
  855. this.msgSuccess("新增成功");
  856. this.groupValue = ''
  857. this.gVis = false
  858. }
  859. })
  860. },
  861. /** 获取分组 */
  862. getGroupList() {
  863. getGroupAllList().then(response => {
  864. this.groupingData = response.data.map((item) => {
  865. return {...item, isUpdata: false}
  866. })
  867. })
  868. },
  869. /** 删除分组 */
  870. handleGroupDel(id){
  871. delGroup(id).then(response => {
  872. if(response.data){
  873. this.msgSuccess("删除成功");
  874. this.getGroupList()
  875. }
  876. })
  877. },
  878. /** 修改分组 */
  879. handleGroupEdit(id){
  880. if(this.newGroupName === ''){
  881. this.$message.error('请输入要修改的分组名字');
  882. return
  883. }
  884. editGroup({ id, groupName: this.newGroupName }).then(response => {
  885. if(response.data){
  886. this.getGroupList()
  887. this.msgSuccess("修改成功");
  888. }
  889. })
  890. },
  891. /** 修改公众号分组 */
  892. editAccountGroup(id, resourceGroupId){
  893. editAccountGroup({id, resourceGroupId}).then(response => {
  894. if(response.data){
  895. this.getList()
  896. this.msgSuccess("设置成功");
  897. }
  898. })
  899. },
  900. /** 导入按钮操作 */
  901. handleImport() {
  902. this.upload.title = "公众号导入";
  903. this.upload.open = true;
  904. },
  905. // 文件上传中处理
  906. handleFileUploadProgress(event, file, fileList) {
  907. this.upload.isUploading = true;
  908. },
  909. // 文件上传成功处理
  910. handleFileSuccess(response, file, fileList) {
  911. this.upload.open = false;
  912. this.upload.isUploading = false;
  913. this.$refs.upload.clearFiles();
  914. this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
  915. this.getList();
  916. },
  917. /** 下载模板操作 */
  918. importTemplate() {
  919. this.download('system/user/importTemplate', {
  920. ...this.queryParams
  921. }, `user_${new Date().getTime()}.xlsx`)
  922. },
  923. // 提交上传文件
  924. submitFileForm() {
  925. this.$refs.upload.submit();
  926. },
  927. /** 复制 */
  928. Copy(value){
  929. Copy(value)
  930. }
  931. }
  932. }
  933. </script>
  934. <style lang="scss">
  935. .el-table {
  936. .warning-row {
  937. background: oldlace;
  938. }
  939. .danger-row {
  940. background: rgb(253, 187, 187);
  941. }
  942. .info-row {
  943. background: #909399;
  944. }
  945. }
  946. .el-table
  947. .el-drawer__header span:focus {
  948. outline: 0;
  949. }
  950. .Space{
  951. width: 10px;
  952. display: inline-block;
  953. }
  954. .my_padding{
  955. margin: 0 10px 10px 10px;
  956. }
  957. .verticalCenter{
  958. display: flex;
  959. flex-direction: column;
  960. justify-content: center;
  961. margin-left: 5px;
  962. &>div.child{
  963. color: rgb(136, 136, 136);
  964. font-size: 13px;
  965. &>span{
  966. color: #606266;
  967. }
  968. }
  969. .font12{
  970. font-size: 12px;
  971. }
  972. }
  973. .copy{
  974. color: #409EFF;
  975. margin-left: 5px;
  976. cursor: pointer;
  977. }
  978. .elli{
  979. display: flex;
  980. justify-content: center;
  981. align-items: center;
  982. span{
  983. flex: 1;
  984. overflow:hidden;
  985. text-overflow:ellipsis;
  986. white-space: nowrap;
  987. }
  988. }
  989. .myElli{
  990. overflow:hidden;
  991. text-overflow:ellipsis;
  992. white-space: nowrap;
  993. }
  994. .grouping{
  995. span{
  996. font-size: 12px;
  997. }
  998. button{
  999. padding: 0;
  1000. }
  1001. }
  1002. .groupingNames{
  1003. padding: 0;
  1004. li{
  1005. list-style: none;
  1006. padding: 5px 2px;
  1007. box-sizing: border-box;
  1008. position: relative;
  1009. cursor: pointer;
  1010. .gnnone{
  1011. display: none;
  1012. }
  1013. .gnTxt{
  1014. overflow: hidden;
  1015. text-overflow:ellipsis;
  1016. white-space: nowrap;
  1017. }
  1018. .gnBts{
  1019. width: 100%;
  1020. height: 100%;
  1021. position: absolute;
  1022. top: 0;
  1023. left: 0;
  1024. .bts{
  1025. position: absolute;
  1026. top: 0;
  1027. right: 0;
  1028. height: 100%;
  1029. width: 50px;
  1030. padding-right: 10px;
  1031. }
  1032. }
  1033. &:hover .gnnone{
  1034. display: block;
  1035. background-color: rgba(211, 211, 211, .5);
  1036. border-radius: 2px;
  1037. }
  1038. i{
  1039. cursor: pointer;
  1040. }
  1041. }
  1042. }
  1043. .custom {
  1044. width: 75% !important;
  1045. }
  1046. .cut {
  1047. padding: 0 10px;
  1048. box-sizing: border-box;
  1049. .button {
  1050. margin-bottom: 10px;
  1051. }
  1052. .el-table .cell {
  1053. line-height: normal;
  1054. }
  1055. ul {
  1056. padding-left: 0;
  1057. .sumitInfo {
  1058. // margin-top: 20px;
  1059. font-weight: 600;
  1060. margin-bottom: 10px;
  1061. .button {
  1062. margin-left: 20px;
  1063. }
  1064. }
  1065. }
  1066. }
  1067. .el-dropdown-link {
  1068. cursor: pointer;
  1069. color: #409EFF;
  1070. font-size: 12px;
  1071. margin-left: 10px;
  1072. }
  1073. .dropdownItem {
  1074. cursor: pointer;
  1075. color: #409EFF;
  1076. font-size: 12px;
  1077. padding: 4px 0;
  1078. }
  1079. </style>