schemeList.vue 4.9 KB

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