assets.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  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" @click="last()">上一页</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" @click="paging(i)">下一页</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. this.currentPage = i;
  90. this.showNextOrLastPageBtn();
  91. }
  92. //200失败
  93. else {
  94. console.log('suc200', res);
  95. }
  96. uni.hideLoading();
  97. },
  98. fail: (res) => {
  99. console.log("请求失败****");
  100. uni.hideLoading();
  101. }
  102. });
  103. },
  104. initPage() {
  105. this.paging(1);
  106. },
  107. last()
  108. {
  109. this.currentPage--;
  110. this.paging(this.currentPage);
  111. },
  112. next()
  113. {
  114. this.currentPage++;
  115. this.paging(this.currentPage);
  116. },
  117. showNextOrLastPageBtn()
  118. {
  119. // if((this.pageTotalNum-this.totalItem)>0)
  120. // {
  121. // this.bShowLastPageBtn = false;
  122. // this.bShowNextPageBtn = false;
  123. // // console.log('0000')
  124. // }
  125. // else
  126. if(this.pageTotalNum==this.currentPage)
  127. {
  128. this.bShowLastPageBtn = true;
  129. this.bShowNextPageBtn = false;
  130. // console.log('11111')
  131. }
  132. else if(1==this.currentPage)
  133. {
  134. this.bShowLastPageBtn = false;
  135. this.bShowNextPageBtn = true;
  136. // console.log('2222')
  137. }
  138. else
  139. {
  140. this.bShowLastPageBtn = true;
  141. this.bShowNextPageBtn = true;
  142. // console.log('333333')
  143. }
  144. if(this.pageTotalNum==1){
  145. this.bShowLastPageBtn = false;
  146. this.bShowNextPageBtn = false;
  147. // console.log('444444')
  148. }
  149. },
  150. addZc(){
  151. uni.chooseFile({
  152. success: (chooseFileRes) =>
  153. {
  154. console.log('选择文件成功')
  155. const tempFilePaths = chooseFileRes.tempFilePaths;
  156. this.$refs.popForm.isShow(true);
  157. this.$refs.popForm.setTitle('添加资产');
  158. let _self = this;
  159. let callback = function(content_arr){
  160. let data = {
  161. "UserID":mydata_userInfo.userID,
  162. "ItemName":content_arr[0].input,
  163. }
  164. uni.showLoading({
  165. title: '上传中'
  166. });
  167. uni.uploadFile({
  168. url: mydata_api + '/item/uploadfile',
  169. filePath: tempFilePaths[0],
  170. name: 'file',
  171. formData:data,
  172. success: (uploadFileRes) => {
  173. console.log("上传资产成功", uploadFileRes);
  174. _self.paging(_self.currentPage);
  175. uni.hideLoading();
  176. },
  177. fail: (res) => {
  178. console.log("上传失败");
  179. uni.hideLoading();
  180. }
  181. });
  182. };
  183. this.$refs.popForm.setContent([
  184. {
  185. 'name':'物品名称',
  186. 'input':'',
  187. 'type' :'text'
  188. }
  189. ],callback);
  190. }
  191. });
  192. },
  193. deleteZc(dataUser)
  194. {
  195. this.$refs.popAlert.isShow(true);
  196. this.$refs.popAlert.setTitle('提示');
  197. let _self = this;
  198. let callback = function(){
  199. let data = {
  200. "UserID":mydata_userInfo.userID,
  201. "ItemID":[dataUser.Id]
  202. }
  203. uni.showLoading({
  204. title: '删除中'
  205. });
  206. uni.request({
  207. header: {
  208. 'Content-Type': 'application/json;charset=UTF-8'
  209. },
  210. url: mydata_api + '/backstage/deleteitem',
  211. method: 'POST',
  212. data: data,
  213. dataType: 'json',
  214. success: (res) => {
  215. //100成功
  216. if (res.data.Code == 100) {
  217. console.log("删除资产成功", res);
  218. _self.paging(_self.currentPage);
  219. }
  220. //200失败
  221. else {
  222. console.log('删除用户资产失败200', res);
  223. }
  224. uni.hideLoading();
  225. },
  226. fail: (res) => {
  227. console.log("删除用户资产失败");
  228. uni.hideLoading();
  229. }
  230. });
  231. }
  232. this.$refs.popAlert.setContent('是否删除资产',callback);
  233. },
  234. }
  235. }
  236. </script>
  237. <style lang="scss">
  238. .m_right {
  239. width: 100%;
  240. margin-top: 5rpx;
  241. padding: 0 150rpx;
  242. background-color: #fff;
  243. box-shadow: 3px 0px 6px 0px rgba(0, 0, 0, 0.1);
  244. .m_right_hander {
  245. text-align: right;
  246. height: 250rpx;
  247. position: relative;
  248. .m_btn_red {
  249. position: absolute;
  250. height: 80rpx;
  251. line-height: 80rpx;
  252. padding: 0 40rpx;
  253. right: 0;
  254. top: 50%;
  255. transform: translateY(-50%);
  256. background: #EA252C;
  257. color: #fff;
  258. }
  259. }
  260. }
  261. tbody tr {
  262. // border-top: 2rpx solid #DDDDDD !important;
  263. border: 2rpx solid #DDDDDD !important;
  264. }
  265. th {
  266. border: 2rpx solid #DDDDDD !important;
  267. }
  268. tbody tr th:first-child {
  269. position: relative;
  270. }
  271. tbody tr th {
  272. font-weight: 400 !important;
  273. height: 140rpx;
  274. line-height: 140rpx;
  275. }
  276. // tbody tr:hover {
  277. // // color: #fff;
  278. // background: #FDEBEC;
  279. // // opacity: 0.08;
  280. // }
  281. .m-table-hander {
  282. background-color: #FFF8F7;
  283. height: 140rpx;
  284. line-height: 140rpx;
  285. font-family: MicrosoftYaHei-Bold, MicrosoftYaHei;
  286. font-weight: bold;
  287. }
  288. .m_edit {
  289. position: absolute;
  290. top: 50%;
  291. left: 50%;
  292. transform: translate(-50%, -50%);
  293. background: rgb(67, 127, 250);
  294. color: rgb(255, 255, 255);
  295. min-width: 130rpx;
  296. }
  297. .m_delete {
  298. // position: absolute;
  299. // top: 50%;
  300. // left: 50%;
  301. // min-width: 130rpx;
  302. // transform: translate(-50%, -50%);
  303. // background: rgb(234, 37, 44);
  304. // color: rgb(255, 255, 255);
  305. background: rgb(234, 37, 44);
  306. color: rgb(255, 255, 255);
  307. }
  308. .m_right_footer {
  309. margin-top: 80rpx;
  310. }
  311. .m_logoimg {
  312. width: 80rpx;
  313. height: 80rpx;
  314. position: absolute;
  315. top: 50%;
  316. left: 50%;
  317. transform: translate(-50%,-50%);
  318. }
  319. .m_paging {
  320. text-align: right;
  321. .m_paging_item {
  322. padding: 10rpx 18rpx;
  323. border: 1rpx solid #DDDDDD;
  324. border-radius: 8rpx;
  325. margin-right: 10rpx;
  326. }
  327. .p_act {
  328. background: #EA252C;
  329. color: #fff;
  330. border: inherit;
  331. }
  332. }
  333. .m_paging_item:hover {
  334. background: #EA252C;
  335. color: #fff;
  336. border: inherit;
  337. }
  338. .m_act1 {
  339. color: #FF0019;
  340. }
  341. </style>