schemeList.vue 5.3 KB

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