project.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  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.totalItem)>0)
  129. // {
  130. // this.bShowLastPageBtn = false;
  131. // this.bShowNextPageBtn = false;
  132. // console.log('0000')
  133. // }
  134. // else
  135. if(this.pageTotalNum==this.currentPage)
  136. {
  137. this.bShowLastPageBtn = true;
  138. this.bShowNextPageBtn = false;
  139. console.log('11111')
  140. }
  141. else if(1==this.currentPage)
  142. {
  143. this.bShowLastPageBtn = false;
  144. this.bShowNextPageBtn = true;
  145. console.log('2222')
  146. }
  147. else
  148. {
  149. this.bShowLastPageBtn = true;
  150. this.bShowNextPageBtn = true;
  151. console.log('333333')
  152. }
  153. if(this.pageTotalNum==1){
  154. this.bShowLastPageBtn = false;
  155. this.bShowNextPageBtn = false;
  156. console.log('444444')
  157. }
  158. },
  159. addProject()
  160. {
  161. uni.chooseFile({
  162. success: (chooseFileRes) =>
  163. {
  164. console.log('选择文件成功')
  165. const tempFilePaths = chooseFileRes.tempFilePaths;
  166. this.$refs.popForm.isShow(true);
  167. this.$refs.popForm.setTitle('添加项目');
  168. let _self = this;
  169. let callback = function(content_arr){
  170. let data = {
  171. "CreateUserID":mydata_userInfo.userID,
  172. "ProjectName":content_arr[0].input,
  173. "Describe":content_arr[1].input,
  174. "Type":content_arr[2].input,
  175. }
  176. uni.showLoading({
  177. title: '上传中'
  178. });
  179. uni.uploadFile({
  180. url: mydata_api + '/project/createprojectnew',
  181. filePath: tempFilePaths[0],
  182. name: 'file',
  183. formData:data,
  184. success: (uploadFileRes) => {
  185. console.log("创建项目成功", uploadFileRes);
  186. _self.paging(_self.currentPage);
  187. uni.hideLoading();
  188. },
  189. fail: (res) => {
  190. console.log("创建项目失败");
  191. uni.hideLoading();
  192. }
  193. });
  194. };
  195. this.$refs.popForm.setContent([
  196. {
  197. 'name':'项目名称',
  198. 'input':'',
  199. 'type' :'text'
  200. },
  201. {
  202. 'name':'项目描述',
  203. 'input':'',
  204. 'type' :'text'
  205. },
  206. {
  207. 'name':'项目类型',
  208. 'input':'',
  209. 'type' :'text'
  210. },
  211. ],callback);
  212. }
  213. });
  214. },
  215. onlineProject(dataUser)
  216. {
  217. // this.$refs.popAlert.isShow(true);
  218. // this.$refs.popAlert.setTitle('提示');
  219. // let _self = this;
  220. // let callback = function(){
  221. // let data = {
  222. // "UserID":mydata_userInfo.userID,
  223. // "ProjectID" : dataUser.Id.toString()
  224. // }
  225. // uni.showLoading({
  226. // title: '上线中'
  227. // });
  228. // uni.request({
  229. // header: {
  230. // 'Content-Type': 'application/json;charset=UTF-8'
  231. // },
  232. // url: mydata_api + '/backstage/deleteproject',
  233. // method: 'POST',
  234. // data: data,
  235. // dataType: 'json',
  236. // success: (res) => {
  237. // //100成功
  238. // if (res.data.Code == 100) {
  239. // console.log("上线成功", res);
  240. // _self.paging(_self.currentPage);
  241. // }
  242. // //200失败
  243. // else {
  244. // console.log('上线失败200', res);
  245. // }
  246. // uni.hideLoading();
  247. // },
  248. // fail: (res) => {
  249. // console.log("上线失败");
  250. // uni.hideLoading();
  251. // }
  252. // });
  253. // }
  254. // this.$refs.popAlert.setContent('是否删除项目',callback);
  255. },
  256. deleteProject(dataUser)
  257. {
  258. this.$refs.popAlert.isShow(true);
  259. this.$refs.popAlert.setTitle('提示');
  260. let _self = this;
  261. let callback = function(){
  262. let data = {
  263. "UserID":mydata_userInfo.userID,
  264. "ProjectID" : dataUser.Id.toString()
  265. }
  266. console.log('data=',data)
  267. uni.showLoading({
  268. title: '删除中'
  269. });
  270. uni.request({
  271. header: {
  272. 'Content-Type': 'application/json;charset=UTF-8'
  273. },
  274. url: mydata_api + '/backstage/deleteproject',
  275. method: 'POST',
  276. data: data,
  277. dataType: 'json',
  278. success: (res) => {
  279. //100成功
  280. if (res.data.Code == 100) {
  281. console.log("删除项目成功", res);
  282. _self.paging(_self.currentPage);
  283. }
  284. //200失败
  285. else {
  286. console.log('删除项目失败200', res);
  287. }
  288. uni.hideLoading();
  289. },
  290. fail: (res) => {
  291. console.log("删除项目失败");
  292. uni.hideLoading();
  293. }
  294. });
  295. }
  296. this.$refs.popAlert.setContent('是否删除项目',callback);
  297. }
  298. }
  299. }
  300. </script>
  301. <style lang="scss">
  302. @import '../../assets/icon/iconfont.css';
  303. .m_right {
  304. width: 100%;
  305. margin-top: 5rpx;
  306. padding: 0 150rpx;
  307. background-color: #fff;
  308. box-shadow: 3px 0px 6px 0px rgba(0, 0, 0, 0.1);
  309. .m_right_hander {
  310. text-align: right;
  311. height: 250rpx;
  312. position: relative;
  313. .m_btn_red {
  314. position: absolute;
  315. height: 80rpx;
  316. line-height: 80rpx;
  317. padding: 0 40rpx;
  318. right: 0;
  319. top: 50%;
  320. transform: translateY(-50%);
  321. background: #EA252C;
  322. color: #fff;
  323. }
  324. }
  325. }
  326. tbody tr {
  327. // border-top: 2rpx solid #DDDDDD !important;
  328. border: 2rpx solid #DDDDDD !important;
  329. }
  330. th {
  331. border: 2rpx solid #DDDDDD !important;
  332. }
  333. tbody tr th {
  334. font-weight: 400 !important;
  335. height: 140rpx;
  336. line-height: 140rpx;
  337. }
  338. // tbody tr:hover {
  339. // // color: #fff;
  340. // background: #FDEBEC;
  341. // // opacity: 0.08;
  342. // }
  343. .m-table-hander {
  344. background-color: #FFF8F7;
  345. height: 140rpx;
  346. line-height: 140rpx;
  347. font-family: MicrosoftYaHei-Bold, MicrosoftYaHei;
  348. font-weight: bold;
  349. }
  350. .m_edit {
  351. // position: absolute;
  352. // top: 50%;
  353. // left: 50%;
  354. // transform: translate(-50%, -50%);
  355. background: rgb(67, 127, 250);
  356. color: rgb(255, 255, 255);
  357. // min-width: 130rpx;
  358. }
  359. .m_delete {
  360. // position: absolute;
  361. // top: 50%;
  362. // left: 50%;
  363. // min-width: 130rpx;
  364. // transform: translate(-50%, -50%);
  365. background: rgb(234, 37, 44);
  366. color: rgb(255, 255, 255);
  367. }
  368. .m_online {
  369. // background: #437FFA;
  370. // position: absolute;
  371. // top: 50%;
  372. // left: 50%;
  373. // min-width: 130rpx;
  374. // transform: translate(-50%, -50%);
  375. background: #437FFA;
  376. color: rgb(255, 255, 255);
  377. }
  378. .m_offline {
  379. background: #FD813B;
  380. position: absolute;
  381. top: 50%;
  382. left: 50%;
  383. min-width: 130rpx;
  384. transform: translate(-50%, -50%);
  385. color: rgb(255, 255, 255);
  386. }
  387. .m_right_footer {
  388. margin-top: 80rpx;
  389. }
  390. .m_paging {
  391. text-align: right;
  392. .m_paging_item {
  393. padding: 10rpx 18rpx;
  394. border: 1rpx solid #DDDDDD;
  395. border-radius: 8rpx;
  396. margin-right: 10rpx;
  397. }
  398. .p_act {
  399. background: #EA252C;
  400. color: #fff;
  401. border: inherit;
  402. }
  403. }
  404. .m_paging_item:hover {
  405. background: #EA252C;
  406. color: #fff;
  407. border: inherit;
  408. }
  409. .m_act1 {
  410. color: #FF0019;
  411. }
  412. </style>