assets.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. <template>
  2. <view class="m_right">
  3. <view class="m_right_hander">
  4. <button size="mini" class="m_btn_red" @click="addZc()">添加资产</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>资产预览图</th>
  11. <th>资产名称</th>
  12. <th>上传人</th>
  13. <th>上传时间</th>
  14. <th>删除</th>
  15. </tr>
  16. </thead>
  17. <tbody>
  18. <tr v-for="(dataUser,dataUserI) in dataUsers_all" :key="dataUserI">
  19. <th>
  20. <image class="m_logoimg" :src="dataUser.Texture_Url" mode=""></image>
  21. </th>
  22. <th>{{dataUser.Name}}</th>
  23. <th>{{dataUser.CreateUserName}}</th>
  24. <th>{{dataUser.UploadTime}}</th>
  25. <th style="position: relative;"><button type="default" size="mini" class="m_delete" @click="deleteZc(dataUser)">删除</button></th>
  26. </tr>
  27. </tbody>
  28. </table>
  29. </view>
  30. <view class="m_right_footer">
  31. <view class="m_paging">
  32. <text class="m_paging_item m_paging_upper" v-show="bShowLastPageBtn">上一页</text>
  33. <text class="m_paging_item" v-for="i in pageTotalNum" @click="paging(i)" :key="i" :class="i==currentPage?'p_act':''">
  34. {{i}}
  35. </text>
  36. <text class="m_paging_item m_paging_lower" v-show="bShowNextPageBtn">下一页</text>
  37. </view>
  38. </view>
  39. <popForm ref="popForm"></popForm>
  40. <popAlert ref="popAlert"></popAlert>
  41. </view>
  42. </template>
  43. <script>
  44. import popForm from '@/components/popForm.vue'
  45. import popAlert from '@/components/popAlert.vue'
  46. export default {
  47. name: "manager_assets",
  48. components: {
  49. popForm,
  50. popAlert,
  51. },
  52. data() {
  53. return {
  54. pageTotalNum:1,
  55. currentPage:1,
  56. totalItem:2,
  57. dataUsers_all: [],
  58. bShowLastPageBtn:false,
  59. bShowNextPageBtn:false,
  60. }
  61. },
  62. methods: {
  63. paging(i) {
  64. uni.showLoading({
  65. title: '加载中'
  66. });
  67. let fromIndex = this.totalItem*(i-1);
  68. let toIndex = fromIndex+this.totalItem;
  69. let data = {
  70. "UserID": mydata_userInfo.userID,
  71. "BeginNum": fromIndex, //用户数组索引
  72. "EndNum": toIndex, //用户数组索引结束
  73. "ItemType":""//道具 角色 场景 空为全部
  74. }
  75. uni.request({
  76. header: {
  77. 'Content-Type': 'application/json;charset=UTF-8'
  78. },
  79. url: mydata_api + '/item/getitemlist',
  80. method: 'POST',
  81. data: data,
  82. dataType: 'json',
  83. success: (res) => {
  84. //100成功
  85. if (res.data.Code == 100) {
  86. console.log("请求全部资产", res);
  87. this.dataUsers_all = res.data.Items;
  88. this.pageTotalNum = Math.ceil(res.data.AllOfItem/this.totalItem);
  89. console.log("this.pageTotalNum=", this.pageTotalNum);
  90. }
  91. //200失败
  92. else {
  93. console.log('suc200', res);
  94. }
  95. uni.hideLoading();
  96. this.showNextOrLastPageBtn();
  97. },
  98. fail: (res) => {
  99. console.log("请求失败****");
  100. uni.hideLoading();
  101. }
  102. });
  103. },
  104. initPage() {
  105. this.paging(1);
  106. },
  107. showNextOrLastPageBtn()
  108. {
  109. if((this.pageTotalNum-this.totalItem)>0)
  110. {
  111. this.bShowLastPageBtn = false;
  112. this.bShowNextPageBtn = false;
  113. // console.log('0000')
  114. }
  115. else if(this.pageTotalNum==this.currentPage)
  116. {
  117. this.bShowLastPageBtn = true;
  118. this.bShowNextPageBtn = false;
  119. // console.log('11111')
  120. }
  121. else if(1==this.currentPage)
  122. {
  123. this.bShowLastPageBtn = false;
  124. this.bShowNextPageBtn = true;
  125. // console.log('2222')
  126. }
  127. else
  128. {
  129. this.bShowLastPageBtn = true;
  130. this.bShowNextPageBtn = true;
  131. // console.log('333333')
  132. }
  133. },
  134. addZc(){
  135. uni.chooseFile({
  136. success: (chooseFileRes) =>
  137. {
  138. console.log('选择文件成功')
  139. const tempFilePaths = chooseFileRes.tempFilePaths;
  140. this.$refs.popForm.isShow(true);
  141. this.$refs.popForm.setTitle('添加资产');
  142. let _self = this;
  143. let callback = function(content_arr){
  144. let data = {
  145. "UserID":mydata_userInfo.userID,
  146. "ItemName":content_arr[0].input,
  147. }
  148. uni.showLoading({
  149. title: '上传中'
  150. });
  151. uni.uploadFile({
  152. url: mydata_api + '/item/uploadfile',
  153. filePath: tempFilePaths[0],
  154. name: 'file',
  155. formData:data,
  156. success: (uploadFileRes) => {
  157. console.log("上传资产成功", uploadFileRes);
  158. _self.paging(_self.currentPage);
  159. uni.hideLoading();
  160. },
  161. fail: (res) => {
  162. console.log("上传失败");
  163. uni.hideLoading();
  164. }
  165. });
  166. };
  167. this.$refs.popForm.setContent([
  168. {
  169. 'name':'物品名称',
  170. 'input':'',
  171. 'type' :'text'
  172. }
  173. ],callback);
  174. }
  175. });
  176. },
  177. deleteZc(dataUser)
  178. {
  179. this.$refs.popAlert.isShow(true);
  180. this.$refs.popAlert.setTitle('提示');
  181. let _self = this;
  182. let callback = function(){
  183. let data = {
  184. "UserID":mydata_userInfo.userID,
  185. "ItemID":[dataUser.Id]
  186. }
  187. uni.showLoading({
  188. title: '删除中'
  189. });
  190. uni.request({
  191. header: {
  192. 'Content-Type': 'application/json;charset=UTF-8'
  193. },
  194. url: mydata_api + '/backstage/deleteitem',
  195. method: 'POST',
  196. data: data,
  197. dataType: 'json',
  198. success: (res) => {
  199. //100成功
  200. if (res.data.Code == 100) {
  201. console.log("删除资产成功", res);
  202. _self.paging(_self.currentPage);
  203. }
  204. //200失败
  205. else {
  206. console.log('删除用户资产失败200', res);
  207. }
  208. uni.hideLoading();
  209. },
  210. fail: (res) => {
  211. console.log("删除用户资产失败");
  212. uni.hideLoading();
  213. }
  214. });
  215. }
  216. this.$refs.popAlert.setContent('是否删除资产',callback);
  217. },
  218. }
  219. }
  220. </script>
  221. <style lang="scss">
  222. .m_right {
  223. width: 100%;
  224. margin-top: 5rpx;
  225. padding: 0 150rpx;
  226. background-color: #fff;
  227. box-shadow: 3px 0px 6px 0px rgba(0, 0, 0, 0.1);
  228. .m_right_hander {
  229. text-align: right;
  230. height: 250rpx;
  231. position: relative;
  232. .m_btn_red {
  233. position: absolute;
  234. height: 80rpx;
  235. line-height: 80rpx;
  236. padding: 0 40rpx;
  237. right: 0;
  238. top: 50%;
  239. transform: translateY(-50%);
  240. background: #EA252C;
  241. color: #fff;
  242. }
  243. }
  244. }
  245. tbody tr {
  246. // border-top: 2rpx solid #DDDDDD !important;
  247. border: 2rpx solid #DDDDDD !important;
  248. }
  249. th {
  250. border: 2rpx solid #DDDDDD !important;
  251. }
  252. tbody tr th:first-child {
  253. position: relative;
  254. }
  255. tbody tr th {
  256. font-weight: 400 !important;
  257. height: 140rpx;
  258. line-height: 140rpx;
  259. }
  260. // tbody tr:hover {
  261. // // color: #fff;
  262. // background: #FDEBEC;
  263. // // opacity: 0.08;
  264. // }
  265. .m-table-hander {
  266. background-color: #FFF8F7;
  267. height: 140rpx;
  268. line-height: 140rpx;
  269. font-family: MicrosoftYaHei-Bold, MicrosoftYaHei;
  270. font-weight: bold;
  271. }
  272. .m_edit {
  273. position: absolute;
  274. top: 50%;
  275. left: 50%;
  276. transform: translate(-50%, -50%);
  277. background: rgb(67, 127, 250);
  278. color: rgb(255, 255, 255);
  279. min-width: 130rpx;
  280. }
  281. .m_delete {
  282. // position: absolute;
  283. // top: 50%;
  284. // left: 50%;
  285. // min-width: 130rpx;
  286. // transform: translate(-50%, -50%);
  287. // background: rgb(234, 37, 44);
  288. // color: rgb(255, 255, 255);
  289. background: rgb(234, 37, 44);
  290. color: rgb(255, 255, 255);
  291. }
  292. .m_right_footer {
  293. margin-top: 80rpx;
  294. }
  295. .m_logoimg {
  296. width: 80rpx;
  297. height: 80rpx;
  298. position: absolute;
  299. top: 50%;
  300. left: 50%;
  301. transform: translate(-50%,-50%);
  302. }
  303. .m_paging {
  304. text-align: right;
  305. .m_paging_item {
  306. padding: 10rpx 18rpx;
  307. border: 1rpx solid #DDDDDD;
  308. border-radius: 8rpx;
  309. margin-right: 10rpx;
  310. }
  311. .p_act {
  312. background: #EA252C;
  313. color: #fff;
  314. border: inherit;
  315. }
  316. }
  317. .m_paging_item:hover {
  318. background: #EA252C;
  319. color: #fff;
  320. border: inherit;
  321. }
  322. .m_act1 {
  323. color: #FF0019;
  324. }
  325. </style>