schemeList.vue 4.3 KB

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