changeRecord.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. <template>
  2. <el-button size="mini" type="text" @click="cutHandle">
  3. <span><i class="el-icon-tickets"></i>变更记录</span>
  4. <el-drawer :title="cutTitle" append-to-body :visible.sync="showCut" direction="rtl" :before-close="cutClose" custom-class="custom">
  5. <div class="cut">
  6. <el-button class="button" type="primary" icon="el-icon-plus" size="mini" @click="handleCutRecord">插入起始记录</el-button>
  7. <el-table :data="cutData" size="mini">
  8. <el-table-column label="开始时间" prop="beginTime" align="center" width="90"/>
  9. <el-table-column label="结束时间" prop="endTime" align="center" width="90"/>
  10. <el-table-column label="资源名称" prop="resourceName" :show-overflow-tooltip="true" align="center" width="100">
  11. <template slot-scope="scope" v-if="scope.row.resourceInfo">
  12. <span>{{scope.row.resourceInfo.resourceName}}</span>
  13. </template>
  14. </el-table-column>
  15. <el-table-column label="资源标识" prop="resourceKey" :show-overflow-tooltip="true" width="120">
  16. <template slot-scope="scope" v-if="scope.row.resourceInfo">
  17. <span>{{scope.row.resourceInfo.resourceKey}}</span>
  18. </template>
  19. </el-table-column>
  20. <el-table-column label="项目组" prop="businessGroupInfo" width="80" :show-overflow-tooltip="true" align="center">
  21. <template slot-scope="scope" v-if="scope.row.businessGroupInfo">
  22. <span>{{scope.row.businessGroupInfo.businessGroupName}}</span>
  23. </template>
  24. </el-table-column>
  25. <el-table-column label="运营" prop="operUserInfo" width="80" :show-overflow-tooltip="true" align="center">
  26. <template slot-scope="scope" v-if="scope.row.operUserInfo">
  27. <span>{{scope.row.operUserInfo.nickname}}</span>
  28. </template>
  29. </el-table-column>
  30. <el-table-column label="投手" prop="operUserInfo" width="80" :show-overflow-tooltip="true" align="center">
  31. <template slot-scope="scope" v-if="scope.row.putUserInfo">
  32. <span>{{scope.row.putUserInfo.nickname}}</span>
  33. </template>
  34. </el-table-column>
  35. <el-table-column label="投放状态" prop="putStatus" width="80" align="center">
  36. <template slot-scope="scope">
  37. <el-tag type="warning" v-if="scope.row.putStatus === 'wait'">待投放</el-tag>
  38. <el-tag type="success" v-else-if="scope.row.putStatus === 'ing'">投放中</el-tag>
  39. <el-tag type="info" v-else-if="scope.row.putStatus === 'stop'">停投</el-tag>
  40. <el-tag type="danger" v-else-if="scope.row.putStatus === 'destroy'">账号已注销</el-tag>
  41. <div v-else>--</div>
  42. </template>
  43. </el-table-column>
  44. <el-table-column label="投放渠道" prop="putChannel" align="center" :show-overflow-tooltip="true" width="80" />
  45. <el-table-column label="期数" prop="periodInfo" width="80" :show-overflow-tooltip="true" align="center">
  46. <template slot-scope="scope" v-if="scope.row.periodInfo">
  47. <div>{{ scope.row.periodInfo.period }}</div>
  48. </template>
  49. </el-table-column>
  50. <el-table-column label="当前书籍" prop="bookInfo" width="90" :show-overflow-tooltip="true" align="center">
  51. <template slot-scope="scope" v-if="scope.row.bookInfo">
  52. <div slot="reference">{{ scope.row.bookInfo.bookName }}</div>
  53. </template>
  54. </el-table-column>
  55. <el-table-column prop="platformInfo" label="书城信息" width="90" :show-overflow-tooltip="true" align="center">
  56. <template slot-scope="scope" v-if="scope.row.platformInfo">
  57. <div>{{ scope.row.platformInfo.platformName }}</div>
  58. </template>
  59. </el-table-column>
  60. <el-table-column prop="createUser" label="操作人" width="90" :show-overflow-tooltip="true" align="center">
  61. <template slot-scope="scope" v-if="scope.row.createUser">
  62. <div>{{ scope.row.createUser.nickname }}</div>
  63. </template>
  64. </el-table-column>
  65. <el-table-column prop="remark" label="备注" :show-overflow-tooltip="true" />
  66. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="150">
  67. <template slot-scope="scope">
  68. <div>
  69. <el-button type="text" @click="insertDownHandle(scope.row, '向后插入')" size="mini">往后插入</el-button>
  70. <el-button type="text" @click="insertDownHandle(scope.row, '修改')" size="mini">修改</el-button>
  71. <el-button type="text" style="color: red" size="mini" @click="delCutHandle(scope.row)">删除</el-button>
  72. </div>
  73. </template>
  74. </el-table-column>
  75. </el-table>
  76. <pagination v-show="totalCut>0" :total="totalCut" :page.sync="cutQueryPlatForm.pageNum" :limit.sync="cutQueryPlatForm.pageSize" @pagination="getCutHandle"/>
  77. </div>
  78. </el-drawer>
  79. <!-- 新增 编辑记录弹窗 -->
  80. <el-dialog
  81. :title="editCutTitle"
  82. :visible.sync="editCutShow"
  83. width="500px"
  84. append-to-body
  85. @close="editCutShow = false"
  86. >
  87. <el-form :model="queryPlatformCutRecord" :rules="rulesCut" ref="platFormCut" label-position="top" :inline="true">
  88. <el-form-item label="开始时间" prop="beginTime">
  89. <el-date-picker v-model="queryPlatformCutRecord.beginTime" size="small" style="width: 140px" format="yyyy-MM-dd" value-format="yyyy-MM-dd" type="date" placeholder="选择开始时间" />
  90. </el-form-item>
  91. <el-form-item label="结束时间" prop="endTime">
  92. <el-date-picker v-model="queryPlatformCutRecord.endTime" size="small" style="width: 140px" format="yyyy-MM-dd" value-format="yyyy-MM-dd" type="date" placeholder="选择开始时间" />
  93. </el-form-item>
  94. <el-form-item label="项目组" prop="businessGroupId">
  95. <el-select v-model="queryPlatformCutRecord.businessGroupId" size="small" placeholder="选择项目组" filterable style="width: 140px" clearable>
  96. <el-option v-for="item in teamsList" :key="item.id" :label="item.businessGroupName" :value="item.id" />
  97. </el-select>
  98. </el-form-item>
  99. <el-form-item label="运营" prop="operUserId">
  100. <el-select v-model="queryPlatformCutRecord.operUserId" size="small" placeholder="选择运营" filterable style="width: 140px" clearable>
  101. <el-option v-for="item in userAll" :key="item.id" :label="item.nickName" :value="item.id" />
  102. </el-select>
  103. </el-form-item>
  104. <el-form-item label="投手" prop="putUserId">
  105. <el-select v-model="queryPlatformCutRecord.putUserId" size="small" placeholder="选择投手" filterable style="width: 140px" clearable>
  106. <el-option v-for="item in userAll" :key="item.id" :label="item.nickName" :value="item.id" />
  107. </el-select>
  108. </el-form-item>
  109. <el-form-item label="期数" prop="periodId">
  110. <el-select v-model="queryPlatformCutRecord.periodId" size="small" placeholder="选择期数" filterable style="width: 140px" clearable>
  111. <el-option v-for="item in periodList" :key="item.id" :label="item.period" :value="item.id" />
  112. </el-select>
  113. </el-form-item>
  114. <el-form-item label="书城" prop="platformId">
  115. <el-select v-model="queryPlatformCutRecord.platformId" @change="selectZh" size="small" placeholder="选择书城" filterable style="width: 140px" clearable>
  116. <el-option v-for="item in bookCity" :key="item.id" :label="item.platformName" :value="item.id" />
  117. </el-select>
  118. </el-form-item>
  119. <el-form-item label="账号" prop="platformAccountId">
  120. <el-select v-model="queryPlatformCutRecord.platformAccountId" :disabled="!queryPlatformCutRecord.platformId" size="small" placeholder="选择账号" filterable style="width: 140px" clearable>
  121. <el-option v-for="item in accList" :key="item.id" :label="item.account" :value="item.id" />
  122. </el-select>
  123. </el-form-item>
  124. <el-form-item label="书" prop="bookId">
  125. <el-select v-model="queryPlatformCutRecord.bookId" size="small" placeholder="选择书" filterable style="width: 140px" clearable>
  126. <el-option v-for="item in bookList" :key="item.id" :label="item.bookName" :value="item.id" />
  127. </el-select>
  128. </el-form-item>
  129. <el-form-item label="投放状态" prop="putStatus">
  130. <el-select v-model="queryPlatformCutRecord.putStatus" size="small" placeholder="选择投放状态" filterable style="width: 140px" clearable>
  131. <el-option label="待投放" value="wait" />
  132. <el-option label="投放中" value="ing" />
  133. <el-option label="停投" value="stop" />
  134. <el-option label="账号已注销" value="destroy" />
  135. </el-select>
  136. </el-form-item>
  137. <el-form-item label="投放渠道" prop="putChannel">
  138. <el-select v-model="queryPlatformCutRecord.putChannel" size="small" placeholder="选择投放渠道" filterable style="width: 140px" clearable>
  139. <el-option label="MP" value="MP" />
  140. <el-option label="GDT" value="GDT" />
  141. <el-option label="头条" value="头条" />
  142. <el-option label="企微" value="企微" />
  143. <el-option label="混投" value="混投" />
  144. <el-option label="ADQ企微" value="ADQ企微" />
  145. <el-option label="头条企微" value="头条企微" />
  146. <el-option label="MP企微" value="MP企微" />
  147. <el-option label="ADQ公众号" value="ADQ公众号" />
  148. </el-select>
  149. </el-form-item>
  150. <el-form-item label="充值模板" prop="rechargeTemplate">
  151. <el-input v-model="queryPlatformCutRecord.rechargeTemplate" size="small" style="width: 140px" placeholder="输入充值模板" />
  152. </el-form-item>
  153. </el-form>
  154. <span slot="footer" class="dialog-footer">
  155. <el-button @click="editCutShow = false">取 消</el-button>
  156. <el-button type="primary" @click="submitCut('platFormCut')">确 定</el-button>
  157. </span>
  158. </el-dialog>
  159. </el-button>
  160. </template>
  161. <script>
  162. import { gitCutRecordList, delCutRecord, insertCutRecord, editCutRecord } from "@/api/accounts/account";
  163. import { getBookAcc } from "@/api/system/books";
  164. export default {
  165. data () {
  166. return {
  167. cutData: [],
  168. cutTitle: '',
  169. showCut: false,
  170. cutQueryPlatForm: {
  171. pageNum: 1,
  172. pageSize: 10
  173. },
  174. editCutShow: false,
  175. editCutTitle: '',
  176. queryPlatformCutRecord: {}, // 新增修改记录保存
  177. rulesCut: {
  178. beginTime: [
  179. { required: true, message: '请选择开始时间', trigger: 'change' }
  180. ]
  181. },
  182. totalCut: 0,
  183. accList: [],
  184. resourceData: {}
  185. }
  186. },
  187. props: {
  188. value: {
  189. type: Object,
  190. default: {},
  191. },
  192. periodList: { // 期数
  193. type: Array,
  194. default: [],
  195. },
  196. bookCity: { // 书城
  197. type: Array,
  198. default: []
  199. },
  200. bookList: { // 书
  201. type: Array,
  202. default: []
  203. },
  204. teamsList: { // 项目组
  205. type: Array,
  206. default: []
  207. },
  208. userAll: { // 运营投手
  209. type: Array,
  210. default: []
  211. },
  212. type: {
  213. type: String,
  214. default: ""
  215. }
  216. },
  217. methods: {
  218. /** 提交记录 */
  219. submitCut(formName) {
  220. this.$refs[formName].validate((valid) => {
  221. if (valid) {
  222. let params = JSON.parse(JSON.stringify(this.queryPlatformCutRecord))
  223. if(params.beginTime) {
  224. params.beginTime = params.beginTime
  225. }
  226. if(params.endTime) {
  227. params.endTime = params.endTime
  228. }
  229. if(!params.id) { // 新增
  230. insertCutRecord(params).then(res => {
  231. this.msgSuccess("插入成功");
  232. this.resetForm(formName);
  233. this.editCutShow = false
  234. this.getCutHandle()
  235. })
  236. } else { // 修改
  237. editCutRecord(params).then(res => {
  238. this.msgSuccess("修改成功");
  239. this.resetForm(formName);
  240. this.editCutShow = false
  241. this.getCutHandle()
  242. })
  243. }
  244. }
  245. })
  246. },
  247. cutHandle() {
  248. let row = {}
  249. if(this.type === 'use') {
  250. row = { ...this.value.resourceInfo, operUserId: this.value.operUserId, putUserId: this.value.putUserId }
  251. } else {
  252. row = { ...this.value }
  253. }
  254. this.cutTitle = row.resourceName
  255. this.showCut = true
  256. this.cutQueryPlatForm.id = row.id
  257. this.cutData = []
  258. this.resourceData = row
  259. this.getCutHandle()
  260. },
  261. getCutHandle() {
  262. gitCutRecordList(this.cutQueryPlatForm).then(res => {
  263. this.cutData = res.data.records
  264. this.totalCut = res.data.total
  265. })
  266. },
  267. /** 新增记录 */
  268. handleCutRecord() {
  269. const { id, businessGroupId, putUserId, operUserId, periodId, platformId, platformAccountId, bookId, putStatus, putChannel, rechargeTemplate } = this.resourceData
  270. this.editCutTitle = '插入起始记录'
  271. this.editCutShow = true
  272. this.queryPlatformCutRecord = {
  273. resourceId: id,
  274. businessGroupId,
  275. operUserId,
  276. putUserId,
  277. periodId,
  278. platformId,
  279. platformAccountId,
  280. bookId,
  281. putStatus,
  282. putChannel,
  283. rechargeTemplate
  284. }
  285. },
  286. /** 向后插入 */
  287. insertDownHandle(item, type) {
  288. this.editCutTitle = `${type}记录`
  289. this.editCutShow = true
  290. let data = {}
  291. if(item.beginTime) {
  292. item.beginTime = item.beginTime.split(' ')[0]
  293. }
  294. if(item.endTime) {
  295. item.endTime = item.endTime.split(' ')[0]
  296. }
  297. const { beginTime, endTime, id, resourceId, businessGroupId, operUserId, putUserId, periodId, platformId, platformAccountId, bookId, putStatus, putChannel, rechargeTemplate } = item
  298. if(type === '修改') {
  299. data = {beginTime, endTime, id}
  300. } else {
  301. data = {lastChangeRecordId: id}
  302. }
  303. this.queryPlatformCutRecord = {
  304. ...data,
  305. resourceId,
  306. businessGroupId,
  307. operUserId,
  308. putUserId,
  309. periodId,
  310. platformId,
  311. platformAccountId,
  312. bookId,
  313. putStatus,
  314. putChannel,
  315. rechargeTemplate
  316. }
  317. if(platformId) {
  318. this.selectZh(platformId, platformAccountId)
  319. }
  320. },
  321. selectZh(e, id) {
  322. // 获取所有账号
  323. this.queryPlatformCutRecord.platformAccountId = id || null
  324. getBookAcc(e).then(res => {
  325. this.accList = res.data
  326. })
  327. },
  328. /** 删除 */
  329. delCutHandle(row) {
  330. this.$confirm('确定删除?', '删除', {
  331. distinguishCancelAndClose: true,
  332. confirmButtonText: '确定',
  333. cancelButtonText: '取消'
  334. }).then(() => {
  335. delCutRecord(row.id).then(res => {
  336. if(res.data) {
  337. this.msgSuccess('删除成功');
  338. this.getCutHandle()
  339. }
  340. })
  341. })
  342. },
  343. /** 关闭切书切平台 */
  344. cutClose() {
  345. this.showCut = false
  346. },
  347. }
  348. }
  349. </script>
  350. <style lang="scss">
  351. .custom {
  352. width: 75% !important;
  353. }
  354. .cut {
  355. padding: 0 10px;
  356. box-sizing: border-box;
  357. .button {
  358. margin-bottom: 10px;
  359. }
  360. .el-table .cell {
  361. line-height: normal;
  362. }
  363. ul {
  364. padding-left: 0;
  365. .sumitInfo {
  366. // margin-top: 20px;
  367. font-weight: 600;
  368. margin-bottom: 10px;
  369. .button {
  370. margin-left: 20px;
  371. }
  372. }
  373. }
  374. }
  375. </style>