accessoryList.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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="btnList">
  7. <u--input placeholder="请输入" type="number" @input="(val) =>inputChange(val,'totalCount',index)"
  8. slot="totalCount" v-model="item.totalCount">
  9. </u--input>
  10. <u--input placeholder="请输入" type="number" @input="(val) =>inputChange(val,'singlePrice',index)"
  11. slot="singlePrice" v-model="item.singlePrice">
  12. </u--input>
  13. </myCard>
  14. </view>
  15. </u-list>
  16. <view class="add" @click="add('add')" v-if="type != 'view'">
  17. <u-icon name="plus" color="#fff"></u-icon>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. import myCard from '@/pages/saleManage/components/myCard.vue'
  23. import {
  24. getWarehouseOutStock,
  25. getIdWarehouseList
  26. } from '@/api/salesServiceManagement/workOrder/index.js';
  27. export default {
  28. components: {
  29. myCard
  30. },
  31. props: {
  32. type: {
  33. type: String,
  34. default: 'edit'
  35. },
  36. itemList: {
  37. type: Array,
  38. default: () => []
  39. },
  40. },
  41. watch: {
  42. itemList: {
  43. handler(newVal) {
  44. let list = JSON.parse(JSON.stringify(newVal));
  45. console.log(list, 'list------- 子组件')
  46. this.tableList = list;
  47. },
  48. deep: true,
  49. immediate: true
  50. }
  51. },
  52. data() {
  53. return {
  54. columns: [
  55. [{
  56. label: '物品名称:',
  57. prop: 'categoryName',
  58. type: 'title',
  59. className: 'perce100',
  60. }],
  61. [{
  62. label: '物品编码:',
  63. prop: 'categoryCode'
  64. }],
  65. [{
  66. label: '型号:',
  67. prop: 'categoryModel'
  68. }, {
  69. label: '规格:',
  70. prop: 'specification',
  71. }],
  72. [{
  73. label: '级别:',
  74. prop: 'level',
  75. }],
  76. [{
  77. label: '数量:',
  78. prop: 'totalCount',
  79. slot: 'totalCount',
  80. }],
  81. [{
  82. label: '单价:',
  83. prop: 'singlePrice',
  84. slot: 'singlePrice',
  85. }],
  86. [{
  87. label: '总价:',
  88. prop: 'totalPrice'
  89. }],
  90. [{
  91. label: '计量单位:',
  92. prop: 'measureUnit'
  93. }],
  94. [{
  95. label: '仓库:',
  96. prop: 'warehouseName'
  97. }],
  98. [{
  99. label: '操作:',
  100. prop: 'action',
  101. type: 'action',
  102. className: 'perce100',
  103. }],
  104. ],
  105. btnList: [{
  106. name: '删除',
  107. apiName: 'del',
  108. btnType: 'primary',
  109. type: '2',
  110. pageUrl: '',
  111. }, ],
  112. tableList: []
  113. }
  114. },
  115. computed: {},
  116. created() {
  117. // uni.$off('updateInfo');
  118. // uni.$on('updateInfo', (data) => {
  119. // data.customize = '5';
  120. // if (data.index || data.index == 0) {
  121. // let index = data.index;
  122. // delete data.index;
  123. // this.$set(this.tableList, index, data);
  124. // return
  125. // }
  126. // this.tableList.push(data);
  127. // })
  128. },
  129. onShow() {
  130. },
  131. methods: {
  132. add() {
  133. console.log(12345)
  134. // uni.navigateTo({
  135. // url: `/pages/salesServiceManagement/workOrder/components/accessoryList`
  136. // })
  137. },
  138. del(index) {
  139. uni.showModal({
  140. title: '确认删除',
  141. content: '确定要删除所选配件数据吗?',
  142. confirmText: '删除',
  143. confirmColor: '#FF4D4F',
  144. success: (res) => {
  145. if (res.confirm) {
  146. this.tableList.splice(index, 1)
  147. } else if (res.cancel) {
  148. // 用户点击了取消按钮
  149. console.log('用户取消删除');
  150. }
  151. }
  152. });
  153. },
  154. inputChange(e, field, index) {
  155. let value = '';
  156. if (field == 'singlePrice') {
  157. value = e.replace(/[^\d.]/g, '');
  158. const parts = value.split('.');
  159. if (parts.length > 2) {
  160. value = parts[0] + '.' + parts.slice(1).join('');
  161. }
  162. if (value.startsWith('0') && value.length > 1 && value[1] !== '.') {
  163. value = value.replace(/^0+/, '');
  164. }
  165. } else {
  166. value = e.replace(/[^\d]/g, '')
  167. if (value.startsWith('0') && value.length > 1) {
  168. value = value.replace(/^0+/, '');
  169. }
  170. }
  171. console.log(value, 'value')
  172. let obj = this.tableList[index];
  173. obj[field] = value;
  174. let num1 = obj.totalCount ? obj.totalCount - 0 : 0;
  175. let num2 = obj.singlePrice ? obj.singlePrice - 0 : 0;
  176. let total = (num1 * num2).toFixed(1);
  177. obj.totalPrice = total;
  178. console.log(obj, 'obj')
  179. console.log(this.tableList, 'tab')
  180. // this.$set(this.tableList,index,)
  181. // obj.settlementPrice = num1 * num2;
  182. },
  183. getTabData() {
  184. return this.tableList || [];
  185. }
  186. }
  187. }
  188. </script>
  189. <style lang="scss" scoped>
  190. @import url('@/pages/salesServiceManagement/demandList/components/invoice.scss');
  191. .scheme {
  192. padding: 10rpx 20rpx;
  193. }
  194. .add {
  195. width: 96rpx;
  196. height: 96rpx;
  197. border-radius: 48rpx;
  198. background: #3c9cff;
  199. position: fixed;
  200. bottom: 100rpx;
  201. right: 24rpx;
  202. display: flex;
  203. align-items: center;
  204. justify-content: center;
  205. }
  206. </style>