schemeList.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <view class="scheme">
  3. <u-list class="listContent">
  4. <view v-for="(item, index) in tableList" :key="index" style="position: relative;">
  5. <myCard :item="item" @del="del(index)" @edit="add('edit',item,index)" :index="index+1"
  6. :columns="columns" :btnList="btnData">
  7. </myCard>
  8. </view>
  9. </u-list>
  10. <view class="add" @click="add('add')" v-if="type != 'view'">
  11. <u-icon name="plus" color="#fff"></u-icon>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. import myCard from '@/pages/saleManage/components/myCard.vue'
  17. import {
  18. getWarehouseOutStock,
  19. getIdWarehouseList
  20. } from '@/api/salesServiceManagement/workOrder/index.js';
  21. export default {
  22. components: {
  23. myCard
  24. },
  25. props: {
  26. type: {
  27. type: String,
  28. default: 'edit'
  29. },
  30. itemList: {
  31. type: Array,
  32. default: () => []
  33. },
  34. },
  35. watch: {
  36. itemList: {
  37. handler(newVal) {
  38. let list = JSON.parse(JSON.stringify(newVal));
  39. console.log(list, 'list-------')
  40. this.tableList = list;
  41. this.setTabData()
  42. },
  43. deep: true,
  44. immediate: true
  45. }
  46. },
  47. data() {
  48. return {
  49. columns: [
  50. [{
  51. label: '名称:',
  52. prop: 'name',
  53. type: 'title',
  54. className: 'perce100',
  55. }],
  56. [{
  57. label: '项目:',
  58. prop: 'typeId',
  59. formatter: (row) => {
  60. let typeId = row.typeId;
  61. return typeId == 1 ?
  62. '工时' :
  63. typeId == 2 ?
  64. '零配件' :
  65. typeId == 3 ?
  66. '差旅费' : ''
  67. }
  68. }],
  69. [{
  70. label: '编码:',
  71. prop: 'code'
  72. }, ],
  73. [{
  74. label: '型号:',
  75. prop: 'categoryModel'
  76. }, {
  77. label: '规格:',
  78. prop: 'specification',
  79. }],
  80. [{
  81. label: '仓库:',
  82. prop: 'warehouseName'
  83. }],
  84. [{
  85. label: '库存:',
  86. prop: 'warehouseNum',
  87. }, {
  88. label: '单位:',
  89. prop: 'measureUnit'
  90. }],
  91. [{
  92. label: '数量:',
  93. prop: 'totalCount',
  94. }, {
  95. label: '单价:',
  96. prop: 'singlePrice'
  97. }],
  98. [{
  99. label: '合计:',
  100. prop: 'settlementPrice',
  101. }],
  102. [{
  103. label: '详细内容:',
  104. prop: 'content'
  105. }],
  106. [{
  107. label: '操作:',
  108. prop: 'action',
  109. type: 'action',
  110. className: 'perce100',
  111. }],
  112. ],
  113. btnList: [{
  114. name: '修改',
  115. apiName: 'edit',
  116. btnType: 'primary',
  117. type: '2',
  118. pageUrl: '',
  119. judge: [{
  120. authorities: '',
  121. }, {
  122. key: 'customize',
  123. value: ['5'],
  124. }]
  125. },
  126. {
  127. name: '删除',
  128. apiName: 'del',
  129. btnType: 'primary',
  130. type: '2',
  131. pageUrl: '',
  132. judge: [{
  133. authorities: '',
  134. }, {
  135. key: 'customize',
  136. value: ['5'],
  137. }]
  138. },
  139. ],
  140. tableList: []
  141. }
  142. },
  143. computed: {
  144. btnData() {
  145. if (this.type == 'view') {
  146. return [];
  147. }
  148. return this.btnList;
  149. }
  150. },
  151. created() {
  152. uni.$off('updateInfo');
  153. uni.$on('updateInfo', (data) => {
  154. console.log(data, 'data ----')
  155. data.customize = '5';
  156. if (data.index || data.index == 0) {
  157. let index = data.index;
  158. delete data.index;
  159. this.$set(this.tableList, index, data);
  160. return
  161. }
  162. this.tableList.push(data);
  163. })
  164. },
  165. onShow() {
  166. },
  167. methods: {
  168. add(type, item = {}, index) {
  169. if (type == 'edit') {
  170. item.index = index;
  171. }
  172. let data = JSON.stringify(item);
  173. uni.navigateTo({
  174. url: `/pages/salesServiceManagement/workOrder/components/schemeAdd?obtain=仓库&type=${type}&data=${data}`
  175. })
  176. },
  177. del(index) {
  178. uni.showModal({
  179. title: '确认删除',
  180. content: '确定要删除所选方案数据吗?',
  181. confirmText: '删除',
  182. confirmColor: '#FF4D4F',
  183. success: (res) => {
  184. if (res.confirm) {
  185. this.tableList.splice(index, 1)
  186. } else if (res.cancel) {
  187. // 用户点击了取消按钮
  188. console.log('用户取消删除');
  189. }
  190. }
  191. });
  192. },
  193. async setTabData() {
  194. this.tableList.forEach(async (item, index) => {
  195. if (item.typeId == 2) {
  196. this.$set(
  197. this.tableList[index],
  198. 'warehouseList',
  199. await getIdWarehouseList({
  200. categoryId: item.categoryId
  201. })
  202. );
  203. if (item.warehouseId) {
  204. this.$set(
  205. this.tableList[index],
  206. 'warehouseNum',
  207. await getWarehouseOutStock({
  208. warehouseId: item.warehouseId,
  209. code: item.code
  210. })
  211. );
  212. }
  213. }
  214. });
  215. },
  216. getTabData() {
  217. let list = this.tableList.map((el) => {
  218. if (el.customize) {
  219. delete el.customize;
  220. }
  221. return el;
  222. })
  223. return list || [];
  224. }
  225. }
  226. }
  227. </script>
  228. <style lang="scss" scoped>
  229. @import url('@/pages/salesServiceManagement/demandList/components/invoice.scss');
  230. .scheme {
  231. padding: 10rpx 20rpx;
  232. }
  233. .add {
  234. width: 96rpx;
  235. height: 96rpx;
  236. border-radius: 48rpx;
  237. background: #3c9cff;
  238. position: fixed;
  239. bottom: 100rpx;
  240. right: 24rpx;
  241. display: flex;
  242. align-items: center;
  243. justify-content: center;
  244. }
  245. </style>