project.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. <template>
  2. <view class="m_right">
  3. <view class="m_right_hander">
  4. <button size="mini" class="m_btn_red" @click="addProject()">添加项目</button>
  5. </view>
  6. <view class="m_right_container">
  7. <table style="width: 100%;border: 1px solid #DDDDDD;border-collapse: collapse">
  8. <thead class="m-table-hander">
  9. <tr>
  10. <!-- <th>
  11. <icon type="" style="color:#EA252C;" class="font_family" :class="checke?'icon-fuxuankuang_weixuanzhong4':'icon-fuxuankuang-true'"></icon>
  12. </th> -->
  13. <th>项目名称</th>
  14. <th>项目创建人</th>
  15. <th>项目创建时间</th>
  16. <th>项目描述</th>
  17. <!-- <th>项目推荐</th> -->
  18. <th>上线</th>
  19. <th>删除</th>
  20. </tr>
  21. </thead>
  22. <tbody>
  23. <tr v-for="(dataUser,dataUserI) in dataUsers_all" :key="dataUserI">
  24. <!-- <th>
  25. <icon type="" style="color:#EA252C;" class="font_family" :class="checke?'icon-fuxuankuang_weixuanzhong4':'icon-fuxuankuang-true'"></icon>
  26. </th> -->
  27. <th>{{dataUser.ProjectName}}</th>
  28. <th>{{dataUser.CreateUserName}}</th>
  29. <th>{{dataUser.CreateTime}}</th>
  30. <th>{{dataUser.Type}}</th>
  31. <!-- <th>{{dataUser.ProjectName}}</th> -->
  32. <th style="position: relative;"><button type="default" size="mini" class="m_online" @click="onlineProject(dataUser)">上线</button></th>
  33. <th style="position: relative;"><button type="default" size="mini" class="m_delete" @click="deleteProject(dataUser)">删除</button></th>
  34. </tr>
  35. </tbody>
  36. </table>
  37. </view>
  38. <view class="m_right_footer">
  39. <view class="m_paging">
  40. <text class="m_paging_item m_paging_upper" v-show="bShowLastPageBtn" @click="last()">上一页</text>
  41. <text class="m_paging_item" :key="i" v-for="i in pageTotalNum" @click="paging(i)" :class="i==currentPage?'p_act':''">
  42. {{i}}
  43. </text>
  44. <text class="m_paging_item m_paging_lower" v-show="bShowNextPageBtn" @click="next()">下一页</text>
  45. </view>
  46. </view>
  47. <popForm ref="popForm"></popForm>
  48. <popAlert ref="popAlert"></popAlert>
  49. </view>
  50. </template>
  51. <script>
  52. import popForm from '@/components/popForm.vue'
  53. import popAlert from '@/components/popAlert.vue'
  54. export default {
  55. name: "project",
  56. components: {
  57. popForm,
  58. popAlert,
  59. },
  60. data() {
  61. return {
  62. pageTotalNum:1,
  63. currentPage:1,
  64. totalItem:2,
  65. dataUsers_all: [],
  66. checke: false,
  67. bShowLastPageBtn:false,
  68. bShowNextPageBtn:false,
  69. }
  70. },
  71. methods: {
  72. paging(i) {
  73. uni.showLoading({
  74. title: '加载中'
  75. });
  76. let fromIndex = this.totalItem*(i-1);
  77. let toIndex = fromIndex+this.totalItem;
  78. let data = {
  79. "UserID": mydata_userInfo.userID,
  80. "BeginNum": fromIndex, //用户数组索引
  81. "EndNum": toIndex, //用户数组索引结束
  82. "ItemType":""//道具 角色 场景 空为全部
  83. }
  84. uni.request({
  85. header: {
  86. 'Content-Type': 'application/json;charset=UTF-8'
  87. },
  88. url: mydata_api + '/backstage/getprojects',
  89. method: 'POST',
  90. data: data,
  91. dataType: 'json',
  92. success: (res) => {
  93. //100成功
  94. if (res.data.Code == 100) {
  95. console.log("请求全部项目", res);
  96. this.dataUsers_all = res.data.Projects;
  97. this.pageTotalNum = Math.ceil(res.data.AllNumOfList/this.totalItem);
  98. this.currentPage = i;
  99. this.showNextOrLastPageBtn();
  100. }
  101. //200失败
  102. else {
  103. console.log('suc200', res);
  104. }
  105. uni.hideLoading();
  106. },
  107. fail: (res) => {
  108. console.log("请求失败****");
  109. uni.hideLoading();
  110. }
  111. });
  112. },
  113. initPage() {
  114. this.paging(1);
  115. },
  116. last()
  117. {
  118. this.currentPage--;
  119. this.paging(this.currentPage);
  120. },
  121. next()
  122. {
  123. this.currentPage++;
  124. this.paging(this.currentPage);
  125. },
  126. showNextOrLastPageBtn()
  127. {
  128. if(this.pageTotalNum==this.currentPage)
  129. {
  130. this.bShowLastPageBtn = true;
  131. this.bShowNextPageBtn = false;
  132. console.log('11111')
  133. }
  134. else if(1==this.currentPage)
  135. {
  136. this.bShowLastPageBtn = false;
  137. this.bShowNextPageBtn = true;
  138. console.log('2222')
  139. }
  140. else
  141. {
  142. this.bShowLastPageBtn = true;
  143. this.bShowNextPageBtn = true;
  144. console.log('333333')
  145. }
  146. if(this.pageTotalNum==1){
  147. this.bShowLastPageBtn = false;
  148. this.bShowNextPageBtn = false;
  149. console.log('444444')
  150. }
  151. },
  152. addProject()
  153. {
  154. uni.chooseFile({
  155. success: (chooseFileRes) =>
  156. {
  157. console.log('选择文件成功')
  158. const tempFilePaths = chooseFileRes.tempFilePaths;
  159. this.$refs.popForm.isShow(true);
  160. this.$refs.popForm.setTitle('添加项目');
  161. let _self = this;
  162. let callback = function(content_arr){
  163. let data = {
  164. "CreateUserID":mydata_userInfo.userID,
  165. "ProjectName":content_arr[0].input,
  166. "Describe":content_arr[1].input,
  167. "Type":content_arr[2].input,
  168. }
  169. uni.showLoading({
  170. title: '上传中'
  171. });
  172. uni.uploadFile({
  173. url: mydata_api + '/project/createprojectnew',
  174. filePath: tempFilePaths[0],
  175. name: 'file',
  176. formData:data,
  177. success: (uploadFileRes) => {
  178. console.log("创建项目成功", uploadFileRes);
  179. _self.paging(_self.currentPage);
  180. uni.hideLoading();
  181. },
  182. fail: (res) => {
  183. console.log("创建项目失败");
  184. uni.hideLoading();
  185. }
  186. });
  187. };
  188. this.$refs.popForm.setContent([
  189. {
  190. 'name':'项目名称',
  191. 'input':'',
  192. 'type' :'text'
  193. },
  194. {
  195. 'name':'项目描述',
  196. 'input':'',
  197. 'type' :'text'
  198. },
  199. {
  200. 'name':'项目类型',
  201. 'input':'',
  202. 'type' :'text'
  203. },
  204. ],callback);
  205. }
  206. });
  207. },
  208. onlineProject(dataUser)
  209. {
  210. // this.$refs.popAlert.isShow(true);
  211. // this.$refs.popAlert.setTitle('提示');
  212. // let _self = this;
  213. // let callback = function(){
  214. // let data = {
  215. // "UserID":mydata_userInfo.userID,
  216. // "ProjectID" : dataUser.Id.toString()
  217. // }
  218. // uni.showLoading({
  219. // title: '上线中'
  220. // });
  221. // uni.request({
  222. // header: {
  223. // 'Content-Type': 'application/json;charset=UTF-8'
  224. // },
  225. // url: mydata_api + '/backstage/deleteproject',
  226. // method: 'POST',
  227. // data: data,
  228. // dataType: 'json',
  229. // success: (res) => {
  230. // //100成功
  231. // if (res.data.Code == 100) {
  232. // console.log("上线成功", res);
  233. // _self.paging(_self.currentPage);
  234. // }
  235. // //200失败
  236. // else {
  237. // console.log('上线失败200', res);
  238. // }
  239. // uni.hideLoading();
  240. // },
  241. // fail: (res) => {
  242. // console.log("上线失败");
  243. // uni.hideLoading();
  244. // }
  245. // });
  246. // }
  247. // this.$refs.popAlert.setContent('是否删除项目',callback);
  248. },
  249. deleteProject(dataUser)
  250. {
  251. this.$refs.popAlert.isShow(true);
  252. this.$refs.popAlert.setTitle('提示');
  253. let _self = this;
  254. let callback = function(){
  255. let data = {
  256. "UserID":mydata_userInfo.userID,
  257. "ProjectID" : dataUser.Id.toString()
  258. }
  259. console.log('data=',data)
  260. uni.showLoading({
  261. title: '删除中'
  262. });
  263. uni.request({
  264. header: {
  265. 'Content-Type': 'application/json;charset=UTF-8'
  266. },
  267. url: mydata_api + '/backstage/deleteproject',
  268. method: 'POST',
  269. data: data,
  270. dataType: 'json',
  271. success: (res) => {
  272. //100成功
  273. if (res.data.Code == 100) {
  274. console.log("删除项目成功", res);
  275. _self.paging(_self.currentPage);
  276. }
  277. //200失败
  278. else {
  279. console.log('删除项目失败200', res);
  280. }
  281. uni.hideLoading();
  282. },
  283. fail: (res) => {
  284. console.log("删除项目失败");
  285. uni.hideLoading();
  286. }
  287. });
  288. }
  289. this.$refs.popAlert.setContent('是否删除项目',callback);
  290. }
  291. }
  292. }
  293. </script>
  294. <style lang="scss">
  295. @import '../../assets/icon/iconfont.css';
  296. // 允许文字被选择
  297. th
  298. {
  299. moz-user-select: -moz-text;
  300. -moz-user-select: text;
  301. -o-user-select: text;
  302. -khtml-user-select: text;
  303. -webkit-user-select: text;
  304. -ms-user-select: text;
  305. user-select: text;
  306. }
  307. .m_right {
  308. width: 100%;
  309. margin-top: 5rpx;
  310. padding: 0 150rpx;
  311. background-color: #fff;
  312. box-shadow: 3px 0px 6px 0px rgba(0, 0, 0, 0.1);
  313. .m_right_hander {
  314. text-align: right;
  315. height: 250rpx;
  316. position: relative;
  317. .m_btn_red {
  318. position: absolute;
  319. height: 80rpx;
  320. line-height: 80rpx;
  321. padding: 0 40rpx;
  322. right: 0;
  323. top: 50%;
  324. transform: translateY(-50%);
  325. background: #EA252C;
  326. color: #fff;
  327. }
  328. }
  329. }
  330. tbody tr {
  331. // border-top: 2rpx solid #DDDDDD !important;
  332. border: 2rpx solid #DDDDDD !important;
  333. }
  334. th {
  335. border: 2rpx solid #DDDDDD !important;
  336. }
  337. tbody tr th {
  338. font-weight: 400 !important;
  339. height: 140rpx;
  340. line-height: 140rpx;
  341. }
  342. // tbody tr:hover {
  343. // // color: #fff;
  344. // background: #FDEBEC;
  345. // // opacity: 0.08;
  346. // }
  347. .m-table-hander {
  348. background-color: #FFF8F7;
  349. height: 140rpx;
  350. line-height: 140rpx;
  351. font-family: MicrosoftYaHei-Bold, MicrosoftYaHei;
  352. font-weight: bold;
  353. }
  354. .m_edit {
  355. // position: absolute;
  356. // top: 50%;
  357. // left: 50%;
  358. // transform: translate(-50%, -50%);
  359. background: rgb(67, 127, 250);
  360. color: rgb(255, 255, 255);
  361. // min-width: 130rpx;
  362. }
  363. .m_delete {
  364. // position: absolute;
  365. // top: 50%;
  366. // left: 50%;
  367. // min-width: 130rpx;
  368. // transform: translate(-50%, -50%);
  369. background: rgb(234, 37, 44);
  370. color: rgb(255, 255, 255);
  371. }
  372. .m_online {
  373. // background: #437FFA;
  374. // position: absolute;
  375. // top: 50%;
  376. // left: 50%;
  377. // min-width: 130rpx;
  378. // transform: translate(-50%, -50%);
  379. background: #437FFA;
  380. color: rgb(255, 255, 255);
  381. }
  382. .m_offline {
  383. background: #FD813B;
  384. position: absolute;
  385. top: 50%;
  386. left: 50%;
  387. min-width: 130rpx;
  388. transform: translate(-50%, -50%);
  389. color: rgb(255, 255, 255);
  390. }
  391. .m_right_footer {
  392. margin-top: 80rpx;
  393. }
  394. .m_paging {
  395. text-align: right;
  396. .m_paging_item {
  397. padding: 10rpx 18rpx;
  398. border: 1rpx solid #DDDDDD;
  399. border-radius: 8rpx;
  400. margin-right: 10rpx;
  401. }
  402. .p_act {
  403. background: #EA252C;
  404. color: #fff;
  405. border: inherit;
  406. }
  407. }
  408. .m_paging_item:hover {
  409. background: #EA252C;
  410. color: #fff;
  411. border: inherit;
  412. }
  413. .m_act1 {
  414. color: #FF0019;
  415. }
  416. </style>