Commit c2274d93f05da0e838cd4e91943983eb7bfb7cd2

Authored by 严涛
1 parent f04a0f09

锁规可填

... ... @@ -2,7 +2,7 @@
2 2 <view class="page">
3 3 <scroll-view class="scroll" scroll-y>
4 4 <view class="lock-page">
5   - <view class="block" v-for="(item, idx) in items" :key="idx">
  5 + <view class="block" v-for="(item, idx) in items" :key="item.raw && (item.raw.id || item.raw.lineId || item.raw.productId) || ('row-' + idx)">
6 6 <view class="block-header">
7 7 <uni-data-checkbox multiple mode="default" :localdata="[{ text: '锁规', value: 'LOCKED' }]"
8 8 :modelValue="item.locked ? ['LOCKED'] : []" @change="onLockChange(idx, $event)" />
... ... @@ -14,73 +14,79 @@
14 14 </view>
15 15
16 16 <uni-list v-show="item.collapsed">
17   - <uni-list-item title="产品名称">
18   - <template v-slot:footer>
19   - <uni-easyinput v-model="item.productName" placeholder="请输入产品名称" :clearable="false"
20   - disabled />
  17 + <uni-list-item class="select-item" :class="item.productName ? 'is-filled' : 'is-empty'" clickable @click="openProductSheet(idx, 'product')" :rightText="item.productName || '请选择产品名称'" showArrow>
  18 + <template v-slot:body>
  19 + <view class="item-title"><text>产品名称</text></view>
21 20 </template>
22 21 </uni-list-item>
23 22 <uni-list-item title="行业">
24 23 <template v-slot:footer>
25   - <uni-easyinput v-model="item.industry" placeholder="请输入行业" :clearable="false"
26   - disabled />
  24 + <uni-easyinput v-model="item.industry" placeholder="请输入行业" />
27 25 </template>
28 26 </uni-list-item>
29 27 <uni-list-item title="牌号">
30 28 <template v-slot:footer>
31   - <uni-easyinput v-model="item.brand" placeholder="请输入牌号" :clearable="false" disabled />
  29 + <uni-easyinput v-model="item.brand" placeholder="请输入牌号" />
32 30 </template>
33 31 </uni-list-item>
34 32 <uni-list-item title="品质">
35 33 <template v-slot:footer>
36   - <uni-easyinput v-model="item.quality" placeholder="请输入品质" :clearable="false" disabled />
  34 + <uni-easyinput v-model="item.quality" placeholder="请输入品质" />
  35 + </template>
  36 + </uni-list-item>
  37 + <uni-list-item title="厚度(mm)">
  38 + <template v-slot:footer>
  39 + <uni-easyinput type="digit" v-model="item.thickness" :inputBorder="false" placeholder="请输入厚度" @input="onNonNegativeInput(idx, 'thickness')" @blur="onNonNegativeBlur(idx, 'thickness', 9)" />
  40 + </template>
  41 + </uni-list-item>
  42 + <uni-list-item title="厚度公差上限(mm)">
  43 + <template v-slot:footer>
  44 + <uni-easyinput type="digit" v-model="item.thicknessTolPos" :inputBorder="false" placeholder="请输入厚度公差上限" @input="onNumberInput(idx, 'thicknessTolPos')" @blur="onNumberBlur(idx, 'thicknessTolPos', 9)" />
  45 + </template>
  46 + </uni-list-item>
  47 + <uni-list-item title="厚度公差下限(mm)">
  48 + <template v-slot:footer>
  49 + <uni-easyinput type="digit" v-model="item.thicknessTolNeg" :inputBorder="false" placeholder="请输入厚度公差下限" @input="onNumberInput(idx, 'thicknessTolNeg')" @blur="onNumberBlur(idx, 'thicknessTolNeg', 9)" />
  50 + </template>
  51 + </uni-list-item>
  52 + <uni-list-item title="宽度(mm)">
  53 + <template v-slot:footer>
  54 + <uni-easyinput type="digit" v-model="item.width" :inputBorder="false" placeholder="请输入宽度" @input="onNonNegativeInput(idx, 'width')" @blur="onNonNegativeBlur(idx, 'width', 9)" />
  55 + </template>
  56 + </uni-list-item>
  57 + <uni-list-item title="宽度公差上限(mm)">
  58 + <template v-slot:footer>
  59 + <uni-easyinput type="digit" v-model="item.widthTolPos" :inputBorder="false" placeholder="请输入宽度公差上限" @input="onNumberInput(idx, 'widthTolPos')" @blur="onNumberBlur(idx, 'widthTolPos', 9)" />
  60 + </template>
  61 + </uni-list-item>
  62 + <uni-list-item title="宽度公差下限(mm)">
  63 + <template v-slot:footer>
  64 + <uni-easyinput type="digit" v-model="item.widthTolNeg" :inputBorder="false" placeholder="请输入宽度公差下限" @input="onNumberInput(idx, 'widthTolNeg')" @blur="onNumberBlur(idx, 'widthTolNeg', 9)" />
  65 + </template>
  66 + </uni-list-item>
  67 + <uni-list-item title="长度(mm)">
  68 + <template v-slot:footer>
  69 + <uni-easyinput type="digit" v-model="item.length" :inputBorder="false" placeholder="请输入长度" @input="onNonNegativeInput(idx, 'length')" @blur="onNonNegativeBlur(idx, 'length', 9)" />
  70 + </template>
  71 + </uni-list-item>
  72 + <uni-list-item title="长度公差上限(mm)">
  73 + <template v-slot:footer>
  74 + <uni-easyinput type="digit" v-model="item.lengthTolPos" :inputBorder="false" placeholder="请输入长度公差上限" @input="onNumberInput(idx, 'lengthTolPos')" @blur="onNumberBlur(idx, 'lengthTolPos', 9)" />
37 75 </template>
38 76 </uni-list-item>
39   - <uni-list-item title="规格(mm)">
  77 + <uni-list-item title="长度公差下限(mm)">
40 78 <template v-slot:footer>
41   - <view class="value value-spec">
42   - <view v-if="item.thickness" class="value-spec_val">{{ item.thickness }}</view>
43   - <view v-if="item.thickness" class="value-spec_box">
44   - <view v-if="item.thicknessTolPos" class="value-spec_box_1">{{
45   - item.thicknessTolPos > 0 ? '+' + item.thicknessTolPos : item.thicknessTolPos
46   - }}
47   - </view>
48   - <view v-if="item.thicknessTolNeg" class="value-spec_box_2">{{
49   - item.thicknessTolNeg > 0 ? '+' + item.thicknessTolNeg : item.thicknessTolNeg
50   - }}
51   - </view>
52   - </view>
53   - <view v-if="item.width" class="value-spec_val p12">*</view>
54   - <view v-if="item.width" class="value-spec_val">{{ item.width }}</view>
55   - <view v-if="item.width" class="value-spec_box">
56   - <view v-if="item.widthTolPos" class="value-spec_box_1">{{ item.widthTolPos > 0 ?
57   - '+' + item.widthTolPos : item.widthTolPos }}
58   - </view>
59   - <view v-if="item.widthTolNeg" class="value-spec_box_2">{{ item.widthTolNeg > 0 ?
60   - '+' + item.widthTolNeg : item.widthTolNeg }}
61   - </view>
62   - </view>
63   - <view v-if="item.length" class="value-spec_val p12">*</view>
64   - <view v-if="item.length" class="value-spec_val">{{ item.length }}</view>
65   - <view v-if="item.length" class="value-spec_box">
66   - <view v-if="item.lengthTolPos" class="value-spec_box_1">{{ item.lengthTolPos > 0
67   - ? '+' + item.lengthTolPos : item.lengthTolPos }}
68   - </view>
69   - <view v-if="item.lengthTolNeg" class="value-spec_box_2">{{ item.lengthTolNeg > 0
70   - ? '+' + item.lengthTolNeg : item.lengthTolNeg }}
71   - </view>
72   - </view>
73   - </view>
  79 + <uni-easyinput type="digit" v-model="item.lengthTolNeg" :inputBorder="false" placeholder="请输入长度公差下限" @input="onNumberInput(idx, 'lengthTolNeg')" @blur="onNumberBlur(idx, 'lengthTolNeg', 9)" />
74 80 </template>
75 81 </uni-list-item>
76 82 <uni-list-item title="物料编码">
77 83 <template v-slot:footer>
78   - <uni-easyinput v-model="item.materialCode" placeholder="请输入物料编码" :clearable="false" disabled />
  84 + <uni-easyinput v-model="item.materialCode" placeholder="请输入物料编码" />
79 85 </template>
80 86 </uni-list-item>
81 87 <uni-list-item title="状态">
82 88 <template v-slot:footer>
83   - <uni-easyinput v-model="item.status" placeholder="请输入状态" :clearable="false" disabled />
  89 + <uni-easyinput v-model="item.status" placeholder="请输入状态" />
84 90 </template>
85 91 </uni-list-item>
86 92 <uni-list-item title="数量">
... ... @@ -104,33 +110,30 @@
104 110 </uni-list-item> -->
105 111 <uni-list-item title="总金额">
106 112 <template v-slot:footer>
107   - <uni-easyinput v-model="item.totalAmount" type="number" :inputBorder="false" disabled
108   - placeholder="" />
  113 + <uni-easyinput v-model="item.totalAmount" type="number" :inputBorder="false" disabled placeholder="" />
109 114 </template>
110 115 </uni-list-item>
111 116 <uni-list-item title="发货日期">
112 117 <template v-slot:footer>
113   - <uni-easyinput v-model="item.deliveryDate" :inputBorder="false" disabled />
  118 + <uni-easyinput v-model="item.deliveryDate" :inputBorder="false" />
114 119 </template>
115 120 </uni-list-item>
116 121 </uni-list>
117 122
118 123 <uni-list v-show="!item.collapsed">
119   - <uni-list-item title="产品名称">
120   - <template v-slot:footer>
121   - <uni-easyinput v-model="item.productName" placeholder="请输入产品名称" :clearable="false"
122   - disabled />
  124 + <uni-list-item class="select-item" :class="item.productName ? 'is-filled' : 'is-empty'" clickable @click="openProductSheet(idx, 'product')" :rightText="item.productName || '请选择产品名称'" showArrow>
  125 + <template v-slot:body>
  126 + <view class="item-title"><text>产品名称</text></view>
123 127 </template>
124 128 </uni-list-item>
125 129 <uni-list-item title="行业">
126 130 <template v-slot:footer>
127   - <uni-easyinput v-model="item.industry" placeholder="请输入行业" :clearable="false"
128   - disabled />
  131 + <uni-easyinput v-model="item.industry" placeholder="请输入行业" />
129 132 </template>
130 133 </uni-list-item>
131 134 <uni-list-item title="牌号">
132 135 <template v-slot:footer>
133   - <uni-easyinput v-model="item.brand" placeholder="请输入牌号" :clearable="false" disabled />
  136 + <uni-easyinput v-model="item.brand" placeholder="请输入牌号" />
134 137 </template>
135 138 </uni-list-item>
136 139
... ... @@ -170,24 +173,36 @@
170 173 </view>
171 174 </view>
172 175 </scroll-view>
173   -
  176 + <SingleSelectSheet :visible.sync="sheet.visible" :title="sheet.title" :options="sheet.options" v-model="sheet.value" @confirm="onProductConfirm" />
174 177 </view>
175 178 </template>
176 179
177 180 <script>
178 181 import { getContractApi, specificationLock } from '@/api/contract'
  182 +import SingleSelectSheet from '@/components/single-select/index.vue'
  183 +import { getDicByCodes } from '@/utils/dic'
179 184 import { formatCurrencyToChinese } from '@/utils/common'
180 185
181 186 export default {
182 187 name: 'ContractUnplanLock',
  188 + components: { SingleSelectSheet },
183 189 data() {
184 190 return {
185 191 id: '',
186 192 items: [],
187 193 planQty: 30,
  194 + sheet: { visible: false, title: '请选择', options: [], idx: -1, value: '', mode: '' },
  195 + options: [],
188 196 }
189 197 },
190 198 computed: {
  199 + selectOptions() {
  200 + const list = Array.isArray(this.options) ? this.options : []
  201 + return list.map(o => ({
  202 + label: o.label != null ? o.label : (o.text != null ? o.text : (o.name != null ? o.name : '')),
  203 + value: o.value != null ? o.value : (o.id != null ? o.id : o.productId)
  204 + }))
  205 + },
191 206 totalQuantity() {
192 207 const qty = this.items.filter(it => it.locked).reduce((p, c) => p + this.toNumber(c.quantity), 0)
193 208 return this.round(qty, 2)
... ... @@ -219,8 +234,40 @@ export default {
219 234 const id = options && options.id ? options.id : ''
220 235 this.id = id
221 236 this.loadDetail()
  237 + this.loadProductOptions()
222 238 },
223 239 methods: {
  240 + onNonNegativeInput(idx, field) {
  241 + const it = this.items[idx]
  242 + if (!it) return
  243 + const raw = it[field]
  244 + it[field] = String(raw || '').replace(/[^0-9.]/g, '')
  245 + this.$set(this.items, idx, it)
  246 + },
  247 + onNumberInput(idx, field) {
  248 + const it = this.items[idx]
  249 + if (!it) return
  250 + const raw = it[field]
  251 + it[field] = String(raw || '').replace(/[^0-9.\-]/g, '')
  252 + this.$set(this.items, idx, it)
  253 + },
  254 + onNonNegativeBlur(idx, field, digits) {
  255 + const it = this.items[idx]
  256 + if (!it) return
  257 + const num = Math.max(0, this.toNumber(it[field]))
  258 + const rounded = this.round(num, digits)
  259 + it[field] = rounded
  260 + this.$set(this.items, idx, it)
  261 + },
  262 + async loadProductOptions() {
  263 + try {
  264 + const results = await getDicByCodes(['CONTRACT_PRODUCT'])
  265 + const c3 = results && results.CONTRACT_PRODUCT && results.CONTRACT_PRODUCT.data ? results.CONTRACT_PRODUCT.data : []
  266 + this.options = c3.map(it => ({ label: it.name, value: it.code }))
  267 + } catch (e) {
  268 + this.options = []
  269 + }
  270 + },
224 271 onLockChange(idx, e) {
225 272 const it = this.items[idx]
226 273 if (!it) return
... ... @@ -238,6 +285,7 @@ export default {
238 285 locked: false,
239 286 collapsed: true,
240 287 raw: v,
  288 + productId: v.productId || v.rawProductId || '',
241 289 productName: v.rawProductName || v.productName || '',
242 290 industry: v.industry || '',
243 291 brand: v.rawProductGrade || v.brand || '',
... ... @@ -272,6 +320,31 @@ export default {
272 320 it.collapsed = !it.collapsed
273 321 this.$set(this.items, idx, it)
274 322 },
  323 + openProductSheet(idx, mode = 'product') {
  324 + let opts = []
  325 + let title = ''
  326 + let value = ''
  327 + const item = this.items[idx]
  328 + if (mode === 'product') {
  329 + opts = this.selectOptions
  330 + const current = item && item.productId
  331 + const match = opts.find(o => o.value === current)
  332 + value = match ? match.value : ''
  333 + title = '请选择产品'
  334 + }
  335 + this.sheet = { ...this.sheet, visible: true, title, options: opts, idx, value, mode }
  336 + },
  337 + onProductConfirm({ value, label }) {
  338 + const { idx, mode } = this.sheet
  339 + const it = this.items[idx]
  340 + if (!it) { this.sheet.visible = false; return }
  341 + if (mode === 'product') {
  342 + it.productId = value
  343 + it.productName = label || ''
  344 + }
  345 + this.$set(this.items, idx, it)
  346 + this.sheet.visible = false
  347 + },
275 348 onImmediateChange(idx) {
276 349 this.$nextTick(() => this.recalculate(idx))
277 350 },
... ... @@ -349,6 +422,26 @@ export default {
349 422 raw.unitPrice = price
350 423 raw.totalAmount = total
351 424 // raw.amountExcludingTax = excl
  425 + raw.productId = it.productId || raw.productId
  426 + raw.productName = it.productName
  427 + if (Object.prototype.hasOwnProperty.call(raw, 'rawProductId')) raw.rawProductId = it.productId || raw.rawProductId
  428 + if (Object.prototype.hasOwnProperty.call(raw, 'rawProductName')) raw.rawProductName = it.productName
  429 + raw.industry = it.industry
  430 + raw.quality = it.quality
  431 + raw.brand = it.brand
  432 + if (Object.prototype.hasOwnProperty.call(raw, 'rawProductGrade')) raw.rawProductGrade = it.brand
  433 + raw.thickness = it.thickness
  434 + raw.thicknessTolPos = it.thicknessTolPos
  435 + raw.thicknessTolNeg = it.thicknessTolNeg
  436 + raw.width = it.width
  437 + raw.widthTolPos = it.widthTolPos
  438 + raw.widthTolNeg = it.widthTolNeg
  439 + raw.length = it.length
  440 + raw.lengthTolPos = it.lengthTolPos
  441 + raw.lengthTolNeg = it.lengthTolNeg
  442 + raw.materialCode = it.materialCode
  443 + raw.status = it.status
  444 + raw.deliveryDate = it.deliveryDate
352 445 return raw
353 446 })
354 447 if (!selected.length) {
... ... @@ -785,4 +878,4 @@ export default {
785 878 height: 60rpx;
786 879 align-items: center;
787 880 }
788   -</style>
\ No newline at end of file
  881 +</style>
... ...
... ... @@ -2,7 +2,7 @@
2 2 <view class="page">
3 3 <scroll-view class="scroll" scroll-y>
4 4 <view class="lock-page">
5   - <view class="block" v-for="(item, idx) in items" :key="idx">
  5 + <view class="block" v-for="(item, idx) in items" :key="item.raw && (item.raw.id || item.raw.lineId || item.raw.productId) || ('row-' + idx)">
6 6 <view class="block-header">
7 7 <uni-data-checkbox
8 8 multiple
... ... @@ -19,63 +19,79 @@
19 19 </view>
20 20
21 21 <uni-list v-show="item.collapsed">
22   - <uni-list-item title="产品名称">
23   - <template v-slot:footer>
24   - <uni-easyinput v-model="item.productName" placeholder="请输入产品名称" :clearable="false" disabled />
  22 + <uni-list-item class="select-item" :class="item.productName ? 'is-filled' : 'is-empty'" clickable @click="openProductSheet(idx, 'product')" :rightText="item.productName || '请选择产品名称'" showArrow>
  23 + <template v-slot:body>
  24 + <view class="item-title"><text>产品名称</text></view>
25 25 </template>
26 26 </uni-list-item>
27 27 <uni-list-item title="行业">
28 28 <template v-slot:footer>
29   - <uni-easyinput v-model="item.industry" placeholder="请输入行业" :clearable="false" disabled />
  29 + <uni-easyinput v-model="item.industry" placeholder="请输入行业" />
30 30 </template>
31 31 </uni-list-item>
32 32 <uni-list-item title="牌号">
33 33 <template v-slot:footer>
34   - <uni-easyinput v-model="item.brand" placeholder="请输入牌号" :clearable="false" disabled />
  34 + <uni-easyinput v-model="item.brand" placeholder="请输入牌号" />
35 35 </template>
36 36 </uni-list-item>
37 37 <uni-list-item title="品质">
38 38 <template v-slot:footer>
39   - <uni-easyinput v-model="item.quality" placeholder="请输入品质" :clearable="false" disabled />
  39 + <uni-easyinput v-model="item.quality" placeholder="请输入品质" />
40 40 </template>
41 41 </uni-list-item>
42   - <uni-list-item title="规格(mm)">
  42 + <uni-list-item title="厚度(mm)">
43 43 <template v-slot:footer>
44   - <view class="value value-spec">
45   - <view v-if="item.thickness" class="value-spec_val">{{ item.thickness }}</view>
46   - <view v-if="item.thickness" class="value-spec_box">
47   - <view v-if="item.thicknessTolPos" class="value-spec_box_1">{{ item.thicknessTolPos > 0 ? '+' + item.thicknessTolPos : item.thicknessTolPos }}
48   - </view>
49   - <view v-if="item.thicknessTolNeg" class="value-spec_box_2">{{ item.thicknessTolNeg > 0 ? '+' + item.thicknessTolNeg : item.thicknessTolNeg }}
50   - </view>
51   - </view>
52   - <view v-if="item.width" class="value-spec_val p12">*</view>
53   - <view v-if="item.width" class="value-spec_val">{{ item.width }}</view>
54   - <view v-if="item.width" class="value-spec_box">
55   - <view v-if="item.widthTolPos" class="value-spec_box_1">{{ item.widthTolPos > 0 ? '+' + item.widthTolPos : item.widthTolPos }}
56   - </view>
57   - <view v-if="item.widthTolNeg" class="value-spec_box_2">{{ item.widthTolNeg > 0 ? '+' + item.widthTolNeg : item.widthTolNeg }}
58   - </view>
59   - </view>
60   - <view v-if="item.length" class="value-spec_val p12">*</view>
61   - <view v-if="item.length" class="value-spec_val">{{ item.length }}</view>
62   - <view v-if="item.length" class="value-spec_box">
63   - <view v-if="item.lengthTolPos" class="value-spec_box_1">{{ item.lengthTolPos > 0 ? '+' + item.lengthTolPos : item.lengthTolPos }}
64   - </view>
65   - <view v-if="item.lengthTolNeg" class="value-spec_box_2">{{ item.lengthTolNeg > 0 ? '+' + item.lengthTolNeg : item.lengthTolNeg }}
66   - </view>
67   - </view>
68   - </view>
  44 + <uni-easyinput type="digit" v-model="item.thickness" :inputBorder="false" placeholder="请输入厚度" @input="onNonNegativeInput(idx, 'thickness')" @blur="onNonNegativeBlur(idx, 'thickness', 9)" />
  45 + </template>
  46 + </uni-list-item>
  47 + <uni-list-item title="厚度公差上限(mm)">
  48 + <template v-slot:footer>
  49 + <uni-easyinput type="digit" v-model="item.thicknessTolPos" :inputBorder="false" placeholder="请输入厚度公差上限" @input="onNumberInput(idx, 'thicknessTolPos')" @blur="onNumberBlur(idx, 'thicknessTolPos', 9)" />
  50 + </template>
  51 + </uni-list-item>
  52 + <uni-list-item title="厚度公差下限(mm)">
  53 + <template v-slot:footer>
  54 + <uni-easyinput type="digit" v-model="item.thicknessTolNeg" :inputBorder="false" placeholder="请输入厚度公差下限" @input="onNumberInput(idx, 'thicknessTolNeg')" @blur="onNumberBlur(idx, 'thicknessTolNeg', 9)" />
  55 + </template>
  56 + </uni-list-item>
  57 + <uni-list-item title="宽度(mm)">
  58 + <template v-slot:footer>
  59 + <uni-easyinput type="digit" v-model="item.width" :inputBorder="false" placeholder="请输入宽度" @input="onNonNegativeInput(idx, 'width')" @blur="onNonNegativeBlur(idx, 'width', 9)" />
  60 + </template>
  61 + </uni-list-item>
  62 + <uni-list-item title="宽度公差上限(mm)">
  63 + <template v-slot:footer>
  64 + <uni-easyinput type="digit" v-model="item.widthTolPos" :inputBorder="false" placeholder="请输入宽度公差上限" @input="onNumberInput(idx, 'widthTolPos')" @blur="onNumberBlur(idx, 'widthTolPos', 9)" />
  65 + </template>
  66 + </uni-list-item>
  67 + <uni-list-item title="宽度公差下限(mm)">
  68 + <template v-slot:footer>
  69 + <uni-easyinput type="digit" v-model="item.widthTolNeg" :inputBorder="false" placeholder="请输入宽度公差下限" @input="onNumberInput(idx, 'widthTolNeg')" @blur="onNumberBlur(idx, 'widthTolNeg', 9)" />
  70 + </template>
  71 + </uni-list-item>
  72 + <uni-list-item title="长度(mm)">
  73 + <template v-slot:footer>
  74 + <uni-easyinput type="digit" v-model="item.length" :inputBorder="false" placeholder="请输入长度" @input="onNonNegativeInput(idx, 'length')" @blur="onNonNegativeBlur(idx, 'length', 9)" />
  75 + </template>
  76 + </uni-list-item>
  77 + <uni-list-item title="长度公差上限(mm)">
  78 + <template v-slot:footer>
  79 + <uni-easyinput type="digit" v-model="item.lengthTolPos" :inputBorder="false" placeholder="请输入长度公差上限" @input="onNumberInput(idx, 'lengthTolPos')" @blur="onNumberBlur(idx, 'lengthTolPos', 9)" />
  80 + </template>
  81 + </uni-list-item>
  82 + <uni-list-item title="长度公差下限(mm)">
  83 + <template v-slot:footer>
  84 + <uni-easyinput type="digit" v-model="item.lengthTolNeg" :inputBorder="false" placeholder="请输入长度公差下限" @input="onNumberInput(idx, 'lengthTolNeg')" @blur="onNumberBlur(idx, 'lengthTolNeg', 9)" />
69 85 </template>
70 86 </uni-list-item>
71 87 <uni-list-item title="物料编码">
72 88 <template v-slot:footer>
73   - <uni-easyinput v-model="item.materialCode" placeholder="请输入物料编码" :clearable="false" disabled />
  89 + <uni-easyinput v-model="item.materialCode" placeholder="请输入物料编码" />
74 90 </template>
75 91 </uni-list-item>
76 92 <uni-list-item title="状态">
77 93 <template v-slot:footer>
78   - <uni-easyinput v-model="item.status" placeholder="请输入状态" :clearable="false" disabled />
  94 + <uni-easyinput v-model="item.status" placeholder="请输入状态" />
79 95 </template>
80 96 </uni-list-item>
81 97 <uni-list-item title="数量">
... ... @@ -100,25 +116,25 @@
100 116 </uni-list-item>
101 117 <uni-list-item title="发货日期">
102 118 <template v-slot:footer>
103   - <uni-easyinput v-model="item.deliveryDate" :inputBorder="false" disabled />
  119 + <uni-easyinput v-model="item.deliveryDate" :inputBorder="false" />
104 120 </template>
105 121 </uni-list-item>
106 122 </uni-list>
107 123
108 124 <uni-list v-show="!item.collapsed">
109   - <uni-list-item title="产品名称">
110   - <template v-slot:footer>
111   - <uni-easyinput v-model="item.productName" placeholder="请输入产品名称" :clearable="false" disabled />
  125 + <uni-list-item class="select-item" :class="item.productName ? 'is-filled' : 'is-empty'" clickable @click="openProductSheet(idx, 'product')" :rightText="item.productName || '请选择产品名称'" showArrow>
  126 + <template v-slot:body>
  127 + <view class="item-title"><text>产品名称</text></view>
112 128 </template>
113 129 </uni-list-item>
114 130 <uni-list-item title="行业">
115 131 <template v-slot:footer>
116   - <uni-easyinput v-model="item.industry" placeholder="请输入行业" :clearable="false" disabled />
  132 + <uni-easyinput v-model="item.industry" placeholder="请输入行业" />
117 133 </template>
118 134 </uni-list-item>
119 135 <uni-list-item title="牌号">
120 136 <template v-slot:footer>
121   - <uni-easyinput v-model="item.brand" placeholder="请输入牌号" :clearable="false" disabled />
  137 + <uni-easyinput v-model="item.brand" placeholder="请输入牌号" />
122 138 </template>
123 139 </uni-list-item>
124 140 </uni-list>
... ... @@ -157,24 +173,52 @@
157 173 </view>
158 174 </view>
159 175 </scroll-view>
160   -
  176 + <SingleSelectSheet :visible.sync="sheet.visible" :title="sheet.title" :options="sheet.options" v-model="sheet.value" @confirm="onProductConfirm" />
161 177 </view>
162 178 </template>
163 179
164 180 <script>
165 181 import { getContractApi, specificationLock } from '@/api/contract'
  182 +import SingleSelectSheet from '@/components/single-select/index.vue'
166 183 import { formatCurrencyToChinese } from '@/utils/common'
  184 +import { getDicByCodes } from '@/utils/dic'
167 185
168 186 export default {
169 187 name: 'ContractUnplanLock',
  188 + components: { SingleSelectSheet },
170 189 data() {
171 190 return {
172 191 id: '',
173 192 items: [],
174 193 planQty: 30,
  194 + sheet: { visible: false, title: '请选择', options: [], idx: -1, value: '', mode: '' },
  195 + options: [],
175 196 }
176 197 },
177 198 computed: {
  199 + selectOptions() {
  200 + const list = Array.isArray(this.options) ? this.options : []
  201 + if (list.length > 0) {
  202 + return list.map(o => ({
  203 + label: o.label != null ? o.label : (o.text != null ? o.text : (o.name != null ? o.name : '')),
  204 + value: o.value != null ? o.value : (o.id != null ? o.id : o.productId)
  205 + }))
  206 + }
  207 + const uniq = {}
  208 + const opts = []
  209 + for (let i = 0; i < this.items.length; i++) {
  210 + const it = this.items[i]
  211 + const id = it.productId || (it.raw && it.raw.productId)
  212 + const name = it.productName || (it.raw && (it.raw.productName || it.raw.rawProductName))
  213 + if (!name) continue
  214 + const key = String(id || name)
  215 + if (uniq[key]) continue
  216 + uniq[key] = true
  217 + opts.push({ label: name, value: id || name })
  218 + }
  219 + return opts
  220 + },
  221 +
178 222 totalQuantity() {
179 223 const qty = this.items.filter(it => it.locked).reduce((p, c) => p + this.toNumber(c.quantity), 0)
180 224 return this.round(qty, 2)
... ... @@ -206,8 +250,40 @@ export default {
206 250 const id = options && options.id ? options.id : ''
207 251 this.id = id
208 252 this.loadDetail()
  253 + this.loadProductOptions()
209 254 },
210 255 methods: {
  256 + async loadProductOptions() {
  257 + try {
  258 + const results = await getDicByCodes(['CONTRACT_PRODUCT'])
  259 + const c3 = results && results.CONTRACT_PRODUCT && results.CONTRACT_PRODUCT.data ? results.CONTRACT_PRODUCT.data : []
  260 + this.options = c3.map(it => ({ label: it.name, value: it.code }))
  261 + } catch (e) {
  262 + this.options = []
  263 + }
  264 + },
  265 + onNonNegativeInput(idx, field) {
  266 + const it = this.items[idx]
  267 + if (!it) return
  268 + const raw = it[field]
  269 + it[field] = String(raw || '').replace(/[^0-9.]/g, '')
  270 + this.$set(this.items, idx, it)
  271 + },
  272 + onNumberInput(idx, field) {
  273 + const it = this.items[idx]
  274 + if (!it) return
  275 + const raw = it[field]
  276 + it[field] = String(raw || '').replace(/[^0-9.\-]/g, '')
  277 + this.$set(this.items, idx, it)
  278 + },
  279 + onNonNegativeBlur(idx, field, digits) {
  280 + const it = this.items[idx]
  281 + if (!it) return
  282 + const num = Math.max(0, this.toNumber(it[field]))
  283 + const rounded = this.round(num, digits)
  284 + it[field] = rounded
  285 + this.$set(this.items, idx, it)
  286 + },
211 287 onLockChange(idx, e) {
212 288 const it = this.items[idx]
213 289 if (!it) return
... ... @@ -225,6 +301,7 @@ export default {
225 301 locked: false,
226 302 collapsed: true,
227 303 raw: v,
  304 + productId: v.productId || v.rawProductId || '',
228 305 productName: v.rawProductName || v.productName || '',
229 306 industry: v.industry || '',
230 307 brand: v.rawProductGrade || v.brand || '',
... ... @@ -262,6 +339,31 @@ export default {
262 339 onImmediateChange(idx) {
263 340 this.$nextTick(() => this.recalculate(idx))
264 341 },
  342 + openProductSheet(idx, mode = 'product') {
  343 + let opts = []
  344 + let title = ''
  345 + let value = ''
  346 + const item = this.items[idx]
  347 + if (mode === 'product') {
  348 + opts = this.selectOptions
  349 + const current = item && item.productId
  350 + const match = opts.find(o => o.value === current)
  351 + value = match ? match.value : ''
  352 + title = '请选择产品'
  353 + }
  354 + this.sheet = { ...this.sheet, visible: true, title, options: opts, idx, value, mode }
  355 + },
  356 + onProductConfirm({ value, label }) {
  357 + const { idx, mode } = this.sheet
  358 + const it = this.items[idx]
  359 + if (!it) { this.sheet.visible = false; return }
  360 + if (mode === 'product') {
  361 + it.productId = value
  362 + it.productName = label || ''
  363 + }
  364 + this.$set(this.items, idx, it)
  365 + this.sheet.visible = false
  366 + },
265 367 onNumberBlur(idx, field, digits) {
266 368 const it = this.items[idx]
267 369 if (!it) return
... ... @@ -336,6 +438,26 @@ export default {
336 438 raw.unitPrice = price
337 439 raw.totalAmount = total
338 440 raw.amountExcludingTax = excl
  441 + raw.productId = it.productId || raw.productId
  442 + raw.productName = it.productName
  443 + if (Object.prototype.hasOwnProperty.call(raw, 'rawProductId')) raw.rawProductId = it.productId || raw.rawProductId
  444 + if (Object.prototype.hasOwnProperty.call(raw, 'rawProductName')) raw.rawProductName = it.productName
  445 + raw.industry = it.industry
  446 + raw.quality = it.quality
  447 + raw.brand = it.brand
  448 + if (Object.prototype.hasOwnProperty.call(raw, 'rawProductGrade')) raw.rawProductGrade = it.brand
  449 + raw.thickness = it.thickness
  450 + raw.thicknessTolPos = it.thicknessTolPos
  451 + raw.thicknessTolNeg = it.thicknessTolNeg
  452 + raw.width = it.width
  453 + raw.widthTolPos = it.widthTolPos
  454 + raw.widthTolNeg = it.widthTolNeg
  455 + raw.length = it.length
  456 + raw.lengthTolPos = it.lengthTolPos
  457 + raw.lengthTolNeg = it.lengthTolNeg
  458 + raw.materialCode = it.materialCode
  459 + raw.status = it.status
  460 + raw.deliveryDate = it.deliveryDate
339 461 return raw
340 462 })
341 463 if (!selected.length) {
... ... @@ -767,4 +889,4 @@ export default {
767 889 height: 60rpx;
768 890 align-items: center;
769 891 }
770   -</style>
\ No newline at end of file
  892 +</style>
... ...