edit.php 120 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322
  1. <?php
  2. use common\helpers\ComponentHelper;
  3. use common\helpers\AddonHelper;
  4. ComponentHelper::loadComponentView('component/com-add-cat', __DIR__);
  5. ComponentHelper::loadComponentView('component/com-attr-group', __DIR__);
  6. ComponentHelper::loadComponentView('component/com-attr', __DIR__);
  7. ComponentHelper::loadComponentView('com-rich-text');
  8. ComponentHelper::loadComponentView('com-district');
  9. ComponentHelper::loadComponentView('component/com-time-select', __DIR__);
  10. ComponentHelper::loadComponentView('component/com-price-set', __DIR__);
  11. ComponentHelper::loadComponentView('component/com-price-day-set', __DIR__);
  12. ComponentHelper::loadComponentView('component/com-attrs-setting', __DIR__);
  13. ComponentHelper::loadComponentView('com-qq-map');
  14. ComponentHelper::loadComponentView('com-dialog-select');
  15. if (!empty($components)) {
  16. foreach ($components as $addons => $component) {
  17. if (!file_exists($component['path'])) continue;
  18. ComponentHelper::loadComponentView($component['component'], $component['path']);
  19. }
  20. $components = \yii\helpers\Json::encode($components);
  21. }
  22. if (!empty($smart_form_components)) {
  23. ComponentHelper::loadComponentView('com-smartform-goods', AddonHelper::getAddonRootPath('SmartForm') . 'backend/views/components');
  24. $smart_form_components = \yii\helpers\Json::encode($smart_form_components);
  25. } else {
  26. $smart_form_components = '{}';
  27. }
  28. if (!empty($community_components)) {
  29. ComponentHelper::loadComponentView('com-community-goods', AddonHelper::getAddonRootPath('Community') . 'backend/views/components');
  30. $community_components = \yii\helpers\Json::encode($community_components);
  31. } else {
  32. $community = '{}';
  33. }
  34. if (!empty($valet_order_components)) {
  35. ComponentHelper::loadComponentView('com-valet-order-goods', AddonHelper::getAddonRootPath('ValetOrder') . 'backend/views/components');
  36. $valet_order_components = \yii\helpers\Json::encode($valet_order_components);
  37. } else {
  38. $valet_order = '{}';
  39. }
  40. ?>
  41. <script src="/resources/js/Sortable.min.js"></script>
  42. <script src="/resources/unpkg/vuedraggable@2.18.1/dist/vuedraggable.umd.min.js"></script>
  43. <style>
  44. <?= ComponentHelper::loadComponentView('edit', __DIR__ . '/css', [], true, 'css'); ?>
  45. </style>
  46. <div id="app" v-cloak>
  47. <el-card shadow="never" style="border:0" class="box-card" body-style="background-color: #f3f3f3;padding: 20px 0 0;" class="box-card" v-loading="cardLoading">
  48. <div slot="header">
  49. <div flex="cross:center box:first">
  50. <div><span @click="$navigate({r:'mall/goods/index'})" class="text">商品列表</span>/添加商品</div>
  51. </div>
  52. </div>
  53. <div class="goods-box">
  54. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" size="mini" label-width="150px" class="demo-ruleForm">
  55. <!-- tab切换 -->
  56. <div class="tabs-box">
  57. <div class="tabs-list" flex="cross:center">
  58. <span v-for="(item, index) in tabs" :key="index" class="tabs-item" :class="item.value == activeName ? 'tabActive' : ''" @click="toggle(item, index, 'tabs')">{{item.name}}</span>
  59. </div>
  60. </div>
  61. <!-- 基础设置 -->
  62. <div v-show="activeName == 'basic'">
  63. <?= ComponentHelper::loadComponentView('goods-basic', __DIR__) ?>
  64. </div>
  65. <!-- 营销配置 -->
  66. <div v-show="activeName == 'marketing'">
  67. <?= ComponentHelper::loadComponentView('goods-marketing', __DIR__) ?>
  68. </div>
  69. <!-- 会员权益 -->
  70. <div v-show="activeName == 'member_benefits'">
  71. <?= ComponentHelper::loadComponentView('goods-member', __DIR__) ?>
  72. </div>
  73. <div v-show="activeName == 'goods_association'">
  74. <?= ComponentHelper::loadComponentView('goods-association', __DIR__) ?>
  75. </div>
  76. <!-- 智能表单 -->
  77. <div v-show="activeName == 'smartform_addons'" v-if="smartform_addons_arr && smartform_addons_arr.component && goodsId > 0">
  78. <com-smartform-goods :goods_id=goodsId ref="smartForm"></com-smartform-goods>
  79. </div>
  80. <!-- 社区团购 -->
  81. <div v-show="activeName == 'community_addons'" v-if="ruleForm.goods_type == 1 && community_addons_arr && community_addons_arr.component">
  82. <com-community-goods :goods_id=goodsId ref="community"></com-community-goods>
  83. </div>
  84. <!-- 代客下单-->
  85. <div v-show="activeName == 'valet_order_addons'" v-if="valet_order_addons_arr && valet_order_addons_arr.component && goodsId > 0">
  86. <com-valet-order-goods :goods_id=goodsId ref="valet_order"></com-valet-order-goods>
  87. </div>
  88. <!-- 支付配置 -->
  89. <div v-show="activeName == 'pay_limit'">
  90. <?= ComponentHelper::loadComponentView('goods-pay', __DIR__) ?>
  91. </div>
  92. </el-form>
  93. </div>
  94. </el-card>
  95. <div class="bottom-btns" flex="main:center cross:center">
  96. <el-button size="mini" type="primary" @click="submit()" :loading="btnLoading">保存</el-button>
  97. </div>
  98. </div>
  99. <script>
  100. const app = new Vue({
  101. el: '#app',
  102. data() {
  103. return {
  104. tabs: [{
  105. name: '基础设置',
  106. value: 'basic'
  107. },
  108. {
  109. name: '营销配置',
  110. value: 'marketing'
  111. },
  112. {
  113. name: '会员权益',
  114. value: 'member_benefits'
  115. },
  116. {
  117. name: '关联商品',
  118. value: 'goods_association'
  119. },
  120. {
  121. name: '支付配置',
  122. value: 'pay_limit'
  123. },
  124. ],
  125. activeName: 'basic',
  126. typeArr: [
  127. // {
  128. // name: '实体商品',
  129. // desc: '物流发货',
  130. // img: '/resources/img/goods/goods.png',
  131. // goods_type: 'physical'
  132. // },
  133. // {
  134. // name: '虚拟商品',
  135. // desc: '无需物流',
  136. // img: '/resources/img/goods/xuni.png',
  137. // goods_type: 'virtual'
  138. // },
  139. // {
  140. // name: '预约商品',
  141. // desc: '无需物流',
  142. // img: '/resources/img/goods/kami.png',
  143. // goods_type: 'reserve'
  144. // }
  145. ],
  146. goods_type: 'physical',
  147. is_base_show: false,
  148. is_mch: false,
  149. is_default_services: 1,
  150. typeIndex: 0,
  151. btnLoading: false,
  152. cardLoading: false,
  153. cats: [],
  154. freight_id: 0,
  155. goodsId: null,
  156. // freight: {
  157. // dialog: false,
  158. // list: [],
  159. // checked: {},
  160. // loading: false
  161. // },
  162. attrGroups: [], //规格组
  163. attrGroupName: '',
  164. attrName: [],
  165. // 批量设置
  166. batch: {},
  167. label_list: [], // 商品标签列表
  168. service_list: [], // 商品服务列表
  169. freight_rules: [ // 运费模板
  170. // {
  171. // id: '1',
  172. // name: '全国包邮'
  173. // },
  174. // {
  175. // id: '2',
  176. // name: '北京包邮'
  177. // }
  178. ],
  179. is_show_freight: false,
  180. defaultMemberPrice: [],
  181. member_level_list: [
  182. // {level: 1, name: '普通会员', value: {"sign_id_2:4":40, "sign_id_3:4": 41, "sign_id_2:5": 41, "sign_id_3:5": 41}},
  183. // {level: 2, name: '等级2', value: {"sign_id_2:4":30, "sign_id_3:4": 31, "sign_id_2:5": 32, "sign_id_3:5": 33}},
  184. // {level: 3, name: '等级3', value: {"sign_id_2:4":20, "sign_id_3:4": 21, "sign_id_2:5": 22, "sign_id_3:5": 23}},
  185. // {level: 4, name: '等级4', value: {"sign_id_2:6":10, "sign_id_3:4": 11, "sign_id_2:5": 12, "sign_id_3:5": 13}}
  186. ],
  187. dialogVisible: false, // 配送范围弹出框
  188. earaRule: [],
  189. show_addons: <?= !empty($components) ? $components : '{}'; ?>, //优惠券是否展示
  190. smartform_addons: <?= !empty($smart_form_components) ? $smart_form_components : '{}'; ?>, //智能表单是否展示
  191. smartform_addons_arr: [],
  192. goods_template_list: [],
  193. community_addons: <?= !empty($community_components) ? $community_components : '{}'; ?>, //智能表单是否展示
  194. valet_order_addons: <?= !empty($valet_order_components) ? $valet_order_components : '{}'; ?>, //智能表单是否展示
  195. community_addons_arr: [],
  196. valet_order_addons_arr: [],
  197. digital_name : '',
  198. marketing_score_calculation_list: [ // 积分营销赠送计算方式选项
  199. {
  200. value: 0,
  201. label: '订单实付金额'
  202. },
  203. {
  204. value: 1,
  205. label: '商品利润'
  206. },
  207. {
  208. value: 2,
  209. label: '商品售价'
  210. }
  211. ],
  212. ruleForm: {
  213. /*********************************** 基础设置 ****************************************/
  214. goods_type: 1,
  215. can_feedback: 1,
  216. goods_name: '',
  217. subtitle: '',
  218. cover_pic: '',
  219. video_cover_pic: '',
  220. bannar_pic: [],
  221. video_url: '',
  222. cats: [],
  223. mchCats: [], //多商户系统分类
  224. services: [],
  225. freight: null,
  226. labels: '', // 商品标签
  227. is_attr: 0, // 是否有规格
  228. attr: [],
  229. price: 0,
  230. original_price: 0,
  231. cost_price: 0,
  232. stock: 0,
  233. unit: '', // 单位
  234. stock_warning: 0, // 库存预警 - 自定义字段,后面改
  235. goods_weight: 0, // 商品重量 - 自定义字段,后面改
  236. goods_no: '', // 商品货号
  237. is_show_stock: 1, // 是否显示库存 - 自定义字段,后面改
  238. is_show_sales: 1, // 是否显示销量 - 自定义字段,后面改
  239. virtual_sales: 0,
  240. coupon_is_enable: 0, //优惠卷的开关
  241. // logistics_way: [{
  242. // name: '快递发货',
  243. // checked: true
  244. // }], // 快递发货 - 自定义字段,后面改
  245. freight_type: [], //物流方式 1快递物流
  246. freight_rules_type: 1, // 运费规则类型 1运费模板 2统一运费
  247. freight_id: '', // 运费模板ID
  248. shipping_fee: 0, //统一运费
  249. free_shipping_num: 0, //满N件包邮
  250. free_shipping_money: 0, //满N元包邮
  251. is_cross_border: 0, // 是否跨境商品 - 自定义字段,后面改
  252. is_id_card: 0, // 是否身份证上传 - 自定义字段,后面改
  253. is_on_sale: 1, // 是否上架
  254. is_show: 1, // 是否上架
  255. goods_subtype: 0, // 商品子类型 0普通商品 1药品商品
  256. extra: {
  257. enable_full_reduce: 0, //是否开启满减
  258. full_reduce_price_limit: 0, // 单品满额减免价格阈值
  259. full_reduce_money: 0, // 单品满额减免金额
  260. score_give_setting: {
  261. code: 'score',
  262. name: '积分',
  263. enable_give_score: 0, //是否开启赠送积分
  264. give_num: 0, // 货币赠送
  265. give_type: 1, // 货币赠送 1.固定值 2售价百分比
  266. settlement: 0, // 结算方式 1.支付完成 0订单完成
  267. enable_limit_level: 0,
  268. limit_level: [],
  269. calculation_value: 0, // 赠送计算方式
  270. score_giving_goods_type: [], //商品类型
  271. score_giving_calculation: 0, //计算方式
  272. },
  273. balance_give_setting: {
  274. enable_give_balance: 0, //是否开启赠送余额
  275. code: 'balance',
  276. name: '余额',
  277. give_num: 0, // 赠送数量
  278. give_type: 1, // 类型 1.固定值 2售价百分比
  279. settlement: 1, // 结算方式:0:订单完成,1:支付完成
  280. },
  281. is_member_price: 0,
  282. is_show_price: 0,
  283. member_price_switch: 0,
  284. member_price_setting: {},
  285. member_buy_limit_setting: {
  286. member_level: [],
  287. every_num: 0,
  288. every_day_num: 0,
  289. every_week_num: 0,
  290. every_month_num: 0,
  291. nums: 0,
  292. total_num: 0,
  293. },
  294. is_member_alone_buy_limit : 0,
  295. member_alone_buy_limit_setting: [],
  296. currency_deduct_setting: [], // 货币这块有bug,暂时不需要展示,所以不需要提交数据
  297. is_repurchase: 0,
  298. repurchase_setting: [],
  299. score_deduct_setting: {
  300. code: 'score',
  301. name: '积分',
  302. is_enable: 0, // 是否启用抵扣
  303. deduct_num: 0, // 抵扣数量
  304. deduct_type: 1, // 1.单件抵扣 2.多件累计抵扣
  305. type: 1,
  306. },
  307. digital_give_setting: {
  308. code: 'digital',
  309. name: '数字币',
  310. give_num: 0, // 货币赠送
  311. give_type: 1, // 货币赠送 1.固定值 2售价百分比
  312. settlement: 0, // 结算方式 1.支付完成 0订单完成
  313. },
  314. is_alone_show_return_btn: 0,//设置独立放弃退换货:0.否,1.是
  315. is_show_return_btn: 1,//是否显示放弃退换货:0.否,1.是
  316. description_template_id: undefined, // 商品说明模板id
  317. symptom_list: [''], // 疾病列表,药品商品类型使用
  318. description_list: [], // 商品说明列表
  319. drug_generic_name: '', // 药品通用名称
  320. },
  321. addons: {},
  322. goods_setting: {
  323. /*********************************** 会员权益 **********************************************/
  324. member_setting: { // 会员权益模块提交的格式
  325. member_price_setting: '',
  326. member_price: {},
  327. member_buy_limit_setting: {
  328. member_level: [],
  329. every_num: 0,
  330. every_day_num: 0,
  331. every_week_num: 0,
  332. every_month_num: 0,
  333. nums: 0,
  334. total_num: 0,
  335. }
  336. },
  337. /*********************************** 营销设置 **********************************************/
  338. marketing_setting: { // 营销配置模块提交的格式
  339. full_reduce_price_limit: 0, // 单品满额减免价格阈值
  340. full_reduce_money: 0, // 单品满额减免金额
  341. score_give_setting: {
  342. code: 'score',
  343. name: '积分',
  344. give_num: 0, // 货币赠送
  345. give_type: 1, // 货币赠送 1.固定值 2售价百分比
  346. settlement: 1, // 结算方式:0订单完成;1支付完成
  347. },
  348. score_deduct_setting: {
  349. code: 'score',
  350. name: '积分',
  351. deduct_num: 0, // 货币抵扣
  352. deduct_type: 1, // 1.单件抵扣 2.多件累计抵扣
  353. },
  354. currency_deduct_setting: [], // 货币这块有bug,暂时不需要展示,所以不需要提交数据
  355. }
  356. },
  357. /******************************* 配送范围 ************************************/
  358. is_area_limit: 0,
  359. // area_limit: [{ list: [] }]
  360. area_limit: [],
  361. goods_template_id: '',
  362. alipay_mini_app_id: null,
  363. extra1_goods_id:[],
  364. extra2_goods_id:[],
  365. is_show_attr: false,
  366. // 预约商品
  367. reserve: {
  368. reserve_date_type: 1, // 可预约时间类型(1范围 2自选日期)
  369. reserve_date: null, // 可预约日期
  370. reserve_time_range_type: 1, //预约模式(1按天预约 2按时间段预约)
  371. time_slot_type: 1, // 时间段划分方式(1自定义划分 2自动划分)
  372. reserve_time_slot: null, // 时间段划分
  373. reserve_price_type: 0, // 价格设置方式(0统一售价 1按日期时间段设置)
  374. reserve_time_slot_price: [], // 按时间段设置的价格
  375. reserve_week: [0,1,2,3,4,5,6], // 可预约周,如:0,1,2,3,4,5,6
  376. reserve_max_buy: 0, // 每天最大预约数量
  377. reserve_advance_hourse: 0, // 提前预约时间(小时)
  378. reserve_days_range: 0, //限制选择并购买的时间在设置内天数的商品
  379. cancel_type: 1, // 取消类型(1不允许取消 2服务开始前取消 3订单类型取消)
  380. cancel_rule: {
  381. cancel_hour: 0,
  382. cancel_fee_percent: 0
  383. }, // 取消规则
  384. expired_handle_type: 1, // 预约码过期后处理方式(1不退款 2自动退款)
  385. service_type: 1, // 服务方式(1上门 2到店)
  386. // 位置信息
  387. province_id: 0, // 省份Id
  388. city_id: 0, // 城市Id
  389. district_id: 0, // 区县Id
  390. detail: '', // 详细地址
  391. lat: '', // 纬度
  392. lng: '', // 经度
  393. skus: [], // 预约多规格
  394. ordering_information: '', // 订购须知
  395. information_detail: '', // 须知详情
  396. reserve_type: 0,
  397. service_min: 0, // 项目时间
  398. },
  399. searchAddress: {
  400. is_enable: 0,
  401. province_id: 0,
  402. city_id: 0,
  403. district_id: 0,
  404. town_id: '',
  405. addressIdsMap: [],
  406. },
  407. is_pay_limit:0,
  408. pay_limit:{
  409. WECHAT:0,
  410. SCORE:0,
  411. BALANCE:0,
  412. ALI:0,
  413. MIXED:0
  414. }
  415. },
  416. smartGoodForm: {},
  417. communityGoodForm: {},
  418. valetOrderGoodForm: {},
  419. rules: {
  420. cats: [{
  421. required: true,
  422. type: 'array',
  423. validator: (rule, value, callback) => {
  424. if (this.ruleForm.cats instanceof Array && this.ruleForm.cats.length > 0) {
  425. callback();
  426. }
  427. callback('请选择分类');
  428. }
  429. }],
  430. mchCats: [{
  431. required: true,
  432. type: 'array',
  433. validator: (rule, value, callback) => {
  434. if (this.ruleForm.mchCats instanceof Array && this.ruleForm.mchCats.length > 0) {
  435. callback();
  436. }
  437. callback('请选择系统分类');
  438. }
  439. }],
  440. goods_name: [{
  441. required: true,
  442. message: '请输入商品名称',
  443. trigger: 'blur'
  444. }],
  445. cover_pic: [{
  446. required: true,
  447. message: '请添加图片',
  448. trigger: 'change'
  449. }],
  450. price: [{
  451. required: true,
  452. message: '请输入价格',
  453. trigger: 'blur'
  454. }],
  455. cost_price: [
  456. {
  457. required: true,
  458. message: '请输入成本价',
  459. trigger: 'blur'
  460. }
  461. ],
  462. original_price: [
  463. {
  464. required: true,
  465. message: '请输入划线价',
  466. trigger: 'blur'
  467. }
  468. ],
  469. stock_warning: [
  470. {
  471. required: true,
  472. message: '请输入库存预警',
  473. trigger: 'blur'
  474. }
  475. ],
  476. goods_weight: [
  477. {
  478. required: true,
  479. message: '请输入商品重量',
  480. trigger: 'blur'
  481. }
  482. ],
  483. extra: {
  484. full_reduce_price_limit: [{
  485. validator: (rule, value, callback) => {
  486. if (value > 1000000) {
  487. callback('不能大于1000000');
  488. }
  489. callback();
  490. }
  491. }],
  492. full_reduce_money: [{
  493. validator: (rule, value, callback) => {
  494. if (value > 1000000) {
  495. callback('不能大于1000000');
  496. }
  497. callback();
  498. }
  499. }],
  500. drug_generic_name: [
  501. {
  502. required: true,
  503. message: '请输入药品通用名称',
  504. trigger: 'blur'
  505. }
  506. ]
  507. },
  508. stock: [{
  509. required: true,
  510. message: '请输入商品库存',
  511. trigger: 'blur'
  512. }],
  513. // area_limit: [{
  514. // required: true,
  515. // type: 'array',
  516. // validator: (rule, value, callback) => {
  517. // if (value instanceof Array && value[0]['list'].length === 0) {
  518. // callback('允许购买区域不能为空');
  519. // }
  520. // callback();
  521. // }
  522. // }],
  523. reserve: {
  524. service_min: [
  525. {
  526. required: true,
  527. message: '请输入项目时间',
  528. trigger: 'blur'
  529. }
  530. ],
  531. cancel_type:[{
  532. validator: (rule, value, callback) => {
  533. if(value=='2' && this.ruleForm.reserve.cancel_rule.cancel_hour ==''){
  534. callback('请填写具体数额');
  535. }
  536. if(value=='3' && this.ruleForm.reserve.cancel_rule.cancel_fee_percent ==''){
  537. callback('请填写具体数额');
  538. }
  539. callback();
  540. }
  541. }
  542. ]
  543. },
  544. attr: [
  545. // 规格属性
  546. {
  547. required: true,
  548. type: 'array',
  549. validator: (rule, value, callback) => {
  550. if (value.length == 0) {
  551. callback('请完善多规格数据')
  552. }
  553. callback()
  554. }
  555. },
  556. // 规格名称
  557. {
  558. required: true,
  559. type: 'array',
  560. validator: (rule, value, callback) => {
  561. if (value.length) {
  562. value.forEach(item => {
  563. if (!(item.attr_list instanceof Array)) {
  564. item.attr_list = Object.values(item.attr_list)
  565. }
  566. item.attr_list.forEach(attr => {
  567. if (attr.attr_group_name == '') {
  568. callback('请完善多规格名称')
  569. }
  570. if (attr.attr_name == '') {
  571. callback('请完善多规格名称')
  572. }
  573. })
  574. })
  575. }
  576. callback()
  577. }
  578. },
  579. // 规格价格
  580. {
  581. required: true,
  582. type: 'array',
  583. validator: (rule, value, callback) => {
  584. if (value.length) {
  585. value.forEach(item => {
  586. if (item.cost_price === '') {
  587. callback('请完善多规格价格')
  588. }
  589. if (item.original_price === '') {
  590. callback('请完善多规格价格')
  591. }
  592. if (item.price === '') {
  593. callback('请完善多规格价格')
  594. }
  595. if (item.stock === '') {
  596. callback('请完善多规格库存')
  597. }
  598. })
  599. }
  600. callback()
  601. }
  602. },
  603. ],
  604. },
  605. revealArea: [],
  606. extra1_goods_list:[],
  607. extra2_goods_list:[],
  608. extra_goods_params: {},
  609. mall_id: <?= $mall_id ?>,
  610. dayArr: [], //预约商品
  611. checkWeekList: [], //预约商品
  612. checkRangeList: [], //预约商品
  613. provinces: {}, //预约商品
  614. provinceInfo: {}, //预约商品
  615. citys: {}, //预约商品
  616. cityInfo: {}, //预约商品
  617. districts: {}, //预约商品
  618. districtInfo: {}, //预约商品
  619. long_lat: '', // 经纬度
  620. initializationDates: [], // 编辑商品时格式化传进来的数据
  621. isEdit: false, // 预约商品,
  622. is_reserve_type: <?= $is_reserve_type ?>,
  623. districtList: [],
  624. townList: [],
  625. goodsAddressProps: {
  626. value: 'id',
  627. label: 'name',
  628. children: 'list',
  629. },
  630. descriptionTemplateList: [], // 商品说明模板
  631. };
  632. },
  633. created() {
  634. //this.smartform_addons_arr = json.parse(this.smartform_addons);
  635. this.smartform_addons_arr = this.smartform_addons;
  636. this.community_addons_arr = this.community_addons;
  637. this.valet_order_addons_arr = this.valet_order_addons;
  638. // 给预约商品一个默认类型
  639. this.ruleForm.reserve.reserve_type = this.is_reserve_type == 2 || this.is_reserve_type == 0 ? 0 : 1
  640. console.log('*****', this.smartform_addons_arr);
  641. this.goodsId = getQuery('id');
  642. this.extra_goods_params['goods_id'] = this.goodsId;
  643. console.log(this.extra_goods_params);
  644. if (this.smartform_addons_arr && this.smartform_addons_arr.component) {
  645. console.log('*****11');
  646. this.tabs.push({
  647. name: '智能表单',
  648. value: 'smartform_addons'
  649. });
  650. }
  651. if (this.community_addons_arr && this.community_addons_arr.component) {
  652. this.tabs.push({
  653. name: '社区团购',
  654. value: 'community_addons'
  655. });
  656. }
  657. if (this.valet_order_addons_arr && this.valet_order_addons_arr.component) {
  658. this.tabs.push({
  659. name: '代客下单',
  660. value: 'valet_order_addons'
  661. });
  662. }
  663. },
  664. async mounted() {
  665. await this.loadData();
  666. this.getDistrict(3);
  667. this.getGoodsDetail();
  668. },
  669. watch: {
  670. 'ruleForm.detail'(newVal, oldVal) {
  671. this.cForm.detail = newVal
  672. },
  673. },
  674. computed: {
  675. cForm() {
  676. let form = {};
  677. let ruleForm = JSON.parse(JSON.stringify(this.ruleForm));
  678. if (this.form) {
  679. form = Object.assign(ruleForm, JSON.parse(JSON.stringify(this.form)));
  680. } else {
  681. form = ruleForm;
  682. }
  683. if (getQuery('id')) {
  684. form.id = getQuery('id')
  685. }
  686. return form;
  687. },
  688. cRule() {
  689. return this.rule ? Object.assign({}, this.rules, this.rule) : this.rules;
  690. },
  691. },
  692. methods: {
  693. assiginObj(target = {}, sources = {}) {
  694. let obj = target;
  695. if (typeof target != 'object' || typeof sources != 'object') {
  696. return sources; // 如果其中一个不是对象 就返回sources
  697. }
  698. for (let key in sources) {
  699. // 如果target也存在 那就再次合并
  700. if (target.hasOwnProperty(key)) {
  701. obj[key] = this.assiginObj(target[key], sources[key]);
  702. } else {
  703. // 不存在就直接添加
  704. obj[key] = sources[key];
  705. }
  706. }
  707. return obj;
  708. },
  709. changeFreightType() {
  710. this.is_show_freight = inArray(1, this.ruleForm.freight_type);
  711. },
  712. getGoodsDetail() {
  713. let self = this;
  714. self.cardLoading = true;
  715. request({
  716. params: {
  717. r: 'mall/goods/edit',
  718. id: getQuery('id')
  719. },
  720. method: 'get',
  721. }).then(e => {
  722. self.cardLoading = false;
  723. if (e.data.code == 0) {
  724. if (!isEmpty(e.data.data.detail)) {
  725. self.typeArr = e.data.data.goods_type;
  726. self.selectCat(e.data.data.detail.cats)
  727. self.attrGroups = e.data.data.detail.attr_groups;
  728. if (!isEmpty(e.data.data.detail.goods_no)) {
  729. e.data.data.detail.goods_no = e.data.data.detail.goods_no.trimEnd();
  730. }
  731. // self.ruleForm = Object.assign(self.ruleForm, e.data.data.detail);
  732. if(e.data.data.detail.goods_type && e.data.data.detail.goods_type == 3){
  733. self.isEdit = true;
  734. self.ruleForm = JSON.parse(JSON.stringify(e.data.data.detail));
  735. if(self.ruleForm.addons == undefined) {
  736. self.ruleForm.addons = {};
  737. }
  738. self.long_lat = self.ruleForm.reserve.lat + '-' + self.ruleForm.reserve.lng;
  739. self.getReservePlace();
  740. if(!(self.ruleForm.reserve && self.ruleForm.reserve.cancel_rule)){
  741. self.ruleForm.reserve.cancel_rule = {
  742. cancel_hour: 0,
  743. cancel_fee_percent: 0
  744. }
  745. }
  746. // 处理cancel_rule空数组的情况
  747. if (self.ruleForm.reserve && JSON.stringify(self.ruleForm.reserve.cancel_rule) == '[]') {
  748. self.ruleForm.reserve.cancel_rule = {}
  749. }
  750. if(this.ruleForm.is_attr == 1){
  751. if(self.ruleForm.reserve && self.ruleForm.reserve.skus && self.ruleForm.reserve.skus.length){
  752. self.ruleForm.attr = [];
  753. let receiveList = self.ruleForm.reserve.skus;
  754. receiveList.forEach(item => {
  755. item.checkRangeList = [];
  756. item.dayArr = [];
  757. item.checkWeekList = [];
  758. item.selectTimeList = [];
  759. item.finalData = [];
  760. if(item.reserve_date_type == 1 && this.ruleForm.reserve.reserve_type == 0){
  761. item.reserve_date.sort(function (a, b) {
  762. return new Date(a) - new Date(b);
  763. });
  764. item.checkRangeList.push(item.reserve_date[0],item.reserve_date[item.reserve_date.length-1]);
  765. let val = [new Date(item.checkRangeList[0]),new Date(item.checkRangeList[1])];
  766. let arr = [];
  767. let txtArr = [{val: 0,txt: '周日',children: []},{val: 1,txt: '周一',children: []},{val: 2,txt: '周二',children: []},{val: 3,txt: '周三',children: []},{val: 4,txt: '周四',children: []},{val: 5,txt: '周五',children: []},{val: 6,txt: '周六',children: []}];
  768. if (val.length) {
  769. let arr1 = [];
  770. let str1 = val[0];
  771. let str2 = val[1];
  772. let unixDb = str1.getTime() - 24 * 60 * 60 * 1000;
  773. let unixDe = str2.getTime() - 24 * 60 * 60 * 1000;
  774. for(let j = unixDb; j <= unixDe;){
  775. j = j + 24 * 60 * 60 * 1000
  776. arr1.push(new Date(parseInt(j)))
  777. }
  778. for(let i = 0; i < arr1.length; i++){
  779. txtArr.forEach(it => {
  780. if(it.val == arr1[i].getDay()){
  781. let fm = this.formatDate(arr1[i])
  782. it.children.push(fm);
  783. }
  784. })
  785. }
  786. txtArr.forEach(it => {
  787. if(it.children.length){
  788. arr.push(it);
  789. }
  790. });
  791. item.dayArr = arr;
  792. }
  793. let warr = [];
  794. item.dayArr.forEach(it => {
  795. warr.push(it.txt);
  796. });
  797. item.checkWeekList = [...new Set(warr)];
  798. let selectArr = [];
  799. let selectDateArr = [];
  800. for(let i = 0; i < item.dayArr.length; i++){
  801. item.checkWeekList.forEach(it => {
  802. if(it == item.dayArr[i].txt){
  803. selectArr.push(item.dayArr[i]);
  804. }
  805. });
  806. }
  807. for(let j = 0; j < selectArr.length; j++){
  808. selectDateArr = selectDateArr.concat(selectArr[j].children);
  809. }
  810. item.reserve_date = selectDateArr;
  811. }
  812. if(item.reserve_time_slot_price && item.reserve_time_slot_price.length){
  813. item.reserve_time_slot_price.forEach(it => {
  814. item.finalData.push({
  815. date: it.reserve_time,
  816. time_spec: it.time_spec,
  817. isSelect: false,
  818. times: [],
  819. selectTimes: [],
  820. });
  821. item.selectTimeList.push({
  822. date: it.reserve_time,
  823. isSelect: false,
  824. children: [],
  825. intervalList: [],
  826. checkAll: false,
  827. isIndeterminate: true,
  828. checkedIntervalList: [],
  829. time_spec: it.time_spec,
  830. });
  831. });
  832. } else if (item.reserve_price_type == 2 && typeof item.reserve_time_slot_price == "object") { // 按天设置价格
  833. for (let day in item.reserve_time_slot_price) {
  834. item.finalData.push({
  835. date: day,
  836. price: item.reserve_time_slot_price[day].price || 0,
  837. linePrice: item.reserve_time_slot_price[day].original_price || 0,
  838. reservationNum: item.reserve_time_slot_price[day].reserve_max_buy || 0,
  839. children: item.reserve_time_slot_price[day].children || [],
  840. times: item.reserve_time_slot_price[day].times || []
  841. })
  842. }
  843. }
  844. item.finalData.forEach(ite => {
  845. if(ite.time_spec && ite.time_spec.length){
  846. ite.time_spec.forEach(it => {
  847. ite.times.push(it.spec_time);
  848. ite.selectTimes.push({
  849. time: it.spec_time,
  850. price: it.price,
  851. linePrice: it.original_price,
  852. reservationNum: it.reserve_max_buy
  853. });
  854. });
  855. }
  856. });
  857. item.selectTimeList.forEach(ite => {
  858. if(ite.time_spec.length){
  859. ite.time_spec.forEach(it => {
  860. ite.children.push(it.spec_time);
  861. });
  862. }
  863. });
  864. });
  865. let targetArr = [];
  866. receiveList.forEach(item => {
  867. targetArr.push({
  868. attr_list: item.attr_list || [],
  869. reserve_date_type: item.reserve_date_type || 1,
  870. reserve_date: item.reserve_date || [],
  871. reserve_time_range_type: item.reserve_time_range_type || 1,
  872. time_slot_type: item.time_slot_type || 1,
  873. reserve_time_slot: item.reserve_time_slot || null,
  874. reserve_price_type: item.reserve_price_type || 0,
  875. reserve_time_slot_price: JSON.parse(JSON.stringify(item.reserve_time_slot_price)) || null,
  876. reserve_week: JSON.parse(JSON.stringify(item.reserve_week)) || [0,1,2,3,4,5,6],
  877. reserve_max_buy: item.reserve_max_buy || null,
  878. price: item.price || null,
  879. original_price: item.original_price || null,
  880. dayArr: item.dayArr || [],
  881. checkWeekList: item.checkWeekList || [],
  882. checkRangeList: item.checkRangeList || [],
  883. selectTimeList: JSON.parse(JSON.stringify(item.selectTimeList)) || [],
  884. finalData: item.finalData || [],
  885. service_min: item.service_min || 0,
  886. unit: item.unit || '',
  887. });
  888. });
  889. targetArr.forEach(item => {
  890. item.selectTimeList.forEach(it => {
  891. it.children = JSON.stringify(it.children);
  892. it.time_spec = JSON.stringify(it.time_spec);
  893. });
  894. });
  895. targetArr.forEach(item => {
  896. let obj = {
  897. attr_list: JSON.parse(JSON.stringify(item.attr_list)),
  898. reserve_date_type: item.reserve_date_type,
  899. reserve_date: JSON.parse(JSON.stringify(item.reserve_date)),
  900. reserve_time_range_type: item.reserve_time_range_type,
  901. time_slot_type: item.time_slot_type,
  902. reserve_time_slot: item.reserve_time_slot,
  903. reserve_price_type: item.reserve_price_type,
  904. reserve_time_slot_price: JSON.parse(JSON.stringify(item.reserve_time_slot_price)),
  905. reserve_week: JSON.parse(JSON.stringify(item.reserve_week)),
  906. reserve_max_buy: item.reserve_max_buy,
  907. price: item.price,
  908. original_price: item.original_price,
  909. dayArr: JSON.parse(JSON.stringify(item.dayArr)),
  910. checkWeekList: JSON.parse(JSON.stringify(item.checkWeekList)),
  911. checkRangeList: JSON.parse(JSON.stringify(item.checkRangeList)),
  912. selectTimeList: JSON.parse(JSON.stringify(item.selectTimeList)),
  913. finalData: JSON.parse(JSON.stringify(item.finalData)),
  914. service_min: item.service_min || 0,
  915. unit: item.unit || '',
  916. }
  917. self.ruleForm.attr.push(JSON.stringify(obj));
  918. });
  919. for(let i = 0; i < self.ruleForm.attr.length; i++){
  920. self.ruleForm.attr[i] = JSON.parse(self.ruleForm.attr[i]);
  921. }
  922. self.ruleForm.attr.forEach(item => {
  923. item.selectTimeList.forEach(it => {
  924. it.children = JSON.parse(it.children);
  925. it.time_spec = JSON.parse(it.time_spec);
  926. });
  927. });
  928. console.log('self.ruleForm.attr',self.ruleForm.attr);
  929. }
  930. }else{
  931. if(self.ruleForm.reserve && self.ruleForm.reserve.reserve_date && self.ruleForm.reserve.reserve_date.length){
  932. if(self.ruleForm.reserve.reserve_date_type == 1){
  933. self.ruleForm.reserve.reserve_date.sort(function (a, b) {
  934. return new Date(a) - new Date(b);
  935. });
  936. self.checkRangeList.push(self.ruleForm.reserve.reserve_date[0],self.ruleForm.reserve.reserve_date[self.ruleForm.reserve.reserve_date.length-1]);
  937. this.dateSelectChange([new Date(self.checkRangeList[0]),new Date(self.checkRangeList[1])]);
  938. }
  939. self.ruleForm.reserve.reserve_time_slot_price.forEach(item => {
  940. self.initializationDates.push({
  941. date: item.reserve_time,
  942. time_spec: item.time_spec,
  943. isSelect: false,
  944. times: [],
  945. selectTimes: []
  946. });
  947. });
  948. self.initializationDates.forEach(item => {
  949. if(item.time_spec.length){
  950. item.time_spec.forEach(it => {
  951. item.times.push(it.spec_time);
  952. item.selectTimes.push({
  953. time: it.spec_time,
  954. price: it.price,
  955. linePrice: it.original_price,
  956. reservationNum: it.reserve_max_buy
  957. });
  958. });
  959. }
  960. });
  961. }
  962. }
  963. }else{
  964. self.ruleForm = self.assiginObj(self.ruleForm, e.data.data.detail);
  965. self.ruleForm.attr = e.data.data.detail.attr;
  966. }
  967. // 因为上面方法赋值物流模版错误需要从新赋值
  968. self.ruleForm.freight_type = e.data.data.detail.freight_type;
  969. self.ruleForm.extra1_goods_id = e.data.data.detail.extra1_goods_id
  970. self.ruleForm.extra2_goods_id = e.data.data.detail.extra2_goods_id
  971. // self.ruleForm.extra.score_give_setting.settlement = self.ruleForm.extra.score_give_setting.settlement.toString()
  972. // console.log(111111111)
  973. console.log(self.ruleForm.extra.score_give_setting.settlement)
  974. console.info(self.ruleForm);
  975. self.cats = e.data.data.detail.cats;
  976. self.ruleForm.freight_type = [];
  977. e.data.data.detail.freight_type.forEach((item, index) => {
  978. self.ruleForm.freight_type[index] = item;
  979. });
  980. console.log('freight_type',self.ruleForm.freight_type);
  981. if (self.ruleForm.freight_type.includes(1)) {
  982. this.is_show_freight = true;
  983. }
  984. self.label_list = e.data.data.labels;
  985. self.service_list = e.data.data.services;
  986. self.goods_template_list = e.data.data.templates;
  987. self.member_level_list = e.data.data.levels;
  988. // 以下数据用于默认规格情况下的 会员价设置
  989. if (!e.data.data.detail.is_attr && e.data.data.detail.is_attr != 0) {
  990. self.member_level_list.forEach((item, index) => {
  991. let obj = {};
  992. obj['id'] = index;
  993. obj['name'] = item.name;
  994. obj['level'] = 'level' + parseInt(item.level);
  995. var key = item.level + '';
  996. self.$set(this.ruleForm.extra.member_price_setting, key, 0);
  997. });
  998. }
  999. // 以下数据用于默认规格情况下的 会员价设置
  1000. var memberSetting = e.data.data.detail.extra;
  1001. self.member_level_list.forEach(function(item, index) {
  1002. let obj = {};
  1003. let key = 'level' + parseInt(item.level);
  1004. obj['id'] = index;
  1005. obj['name'] = item.name;
  1006. obj['level'] = key;
  1007. if (memberSetting && memberSetting.member_price_setting && memberSetting.member_price_setting[key]) {
  1008. self.member_level_list[index]['value'] = memberSetting.member_price_setting[key]; // 赋值到会员列表数据中
  1009. } else {
  1010. self.member_level_list[index]['value'] = {};
  1011. }
  1012. self.defaultMemberPrice.push(obj);
  1013. });
  1014. if (self.ruleForm.area_limit) {
  1015. self.deduplicationArea();
  1016. }
  1017. if (!isEmpty(memberSetting?.description_list)) {
  1018. this.$set(self.ruleForm.extra, 'description_list', memberSetting.description_list)
  1019. }
  1020. if (this.ruleForm?.extra?.description_template_id == 0) {
  1021. this.ruleForm.extra.description_template_id = undefined
  1022. }
  1023. }
  1024. this.$forceUpdate();
  1025. self.freight_rules = e.data.data.freight_rules;
  1026. // 默认运费模板
  1027. if (self.ruleForm.freight_rules_type == 1 && isEmpty(self.ruleForm.freight_id) && self.freight_rules.length > 0) {
  1028. self.ruleForm.freight_id = self.freight_rules[0].id;
  1029. }
  1030. this.extra1_goods_list = e.data.data.extra1_goods_list;
  1031. this.extra2_goods_list = e.data.data.extra2_goods_list;
  1032. self.digital_name = e.data.data.detail.digital_name;
  1033. console.log(self.digital_name);
  1034. if(this.ruleForm.searchAddress.district_id > 0){
  1035. this.getTownList(this.ruleForm.searchAddress.district_id)
  1036. }
  1037. this.descriptionTemplateList = e.data.data.descriptionTemplateList
  1038. } else {
  1039. self.$message.error(e.data.msg);
  1040. }
  1041. }).catch(e => {
  1042. console.log(e);
  1043. });
  1044. },
  1045. /* 配送范围start */
  1046. openDistrict() {
  1047. this.dialogVisible = true;
  1048. this.earaRule = this.ruleForm.area_limit;
  1049. },
  1050. selectDistrict(e) {
  1051. let list = [];
  1052. for (let i in e) {
  1053. let obj = {
  1054. id: e[i].id,
  1055. name: e[i].name
  1056. };
  1057. list.push(obj);
  1058. }
  1059. this.earaRule = list;
  1060. },
  1061. districtConfirm() {
  1062. this.ruleForm.area_limit = JSON.parse(JSON.stringify(this.earaRule));
  1063. this.revealArea = this.earaRule
  1064. // this.deduplicationArea();
  1065. this.dialogVisible = false;
  1066. // this.$refs['ruleForm'].validate((valid) => {
  1067. // return false;
  1068. // })
  1069. },
  1070. deduplicationArea() {
  1071. let that = this;
  1072. let reg = /市$|特别行政区$/;
  1073. let filt = [...new Set(this.ruleForm.area_limit.filter(v => reg.test(v.name)).map(v => v.name))];
  1074. this.ruleForm.area_limit.forEach(v => {
  1075. let length = that.revealArea.filter(f => f.name == v.name).length;
  1076. if (filt.findIndex(f => f == v.name) != -1 && length > 0) {
  1077. return;
  1078. }
  1079. that.revealArea.push(v);
  1080. })
  1081. },
  1082. space() { // 删除地区
  1083. this.ruleForm.area_limit = [];
  1084. },
  1085. /* 配送范围end */
  1086. showMore(type) { // 展开更多
  1087. switch (type) {
  1088. case 'base':
  1089. this.is_base_show = !this.is_base_show
  1090. }
  1091. },
  1092. toggle(it, i, type) { // tab切换
  1093. switch (type) {
  1094. case 'tabs':
  1095. this.activeName = it.value
  1096. break;
  1097. case 'select':
  1098. if (this.ruleForm.id > 0) return;
  1099. this.ruleForm.goods_type = it.type
  1100. if (this.ruleForm.goods_type != 1) {
  1101. this.$set(this.ruleForm, 'goods_subtype', 0)
  1102. }
  1103. if (this.ruleForm.goods_type !== 2) {
  1104. this.ruleForm.can_feedback = 1;
  1105. } else {
  1106. this.ruleForm.can_feedback = 0;
  1107. }
  1108. break;
  1109. default:
  1110. break;
  1111. }
  1112. },
  1113. coverPic(e) { // 选择图片
  1114. this.ruleForm.cover_pic = e[0].url
  1115. },
  1116. videoCoverPic(e) { // 选择图片
  1117. this.ruleForm.video_cover_pic = e[0].url
  1118. },
  1119. bannerPic(e) { // 选择轮播图
  1120. if (e.length) {
  1121. e.forEach((item, index) => {
  1122. if (this.ruleForm.bannar_pic.length >= 9) return;
  1123. this.ruleForm.bannar_pic.push({
  1124. id: item.id,
  1125. pic_url: item.url
  1126. });
  1127. })
  1128. }
  1129. },
  1130. delPic(type, index) { // 删除图片
  1131. switch (type) {
  1132. case 'cover_pic':
  1133. this.ruleForm.cover_pic = ''
  1134. break;
  1135. case 'bannar_pic':
  1136. this.ruleForm.bannar_pic.splice(index, 1)
  1137. break;
  1138. case 'video_cover_pic':
  1139. this.ruleForm.video_cover_pic = '';
  1140. break;
  1141. default:
  1142. break;
  1143. }
  1144. },
  1145. // 商品视频
  1146. videoUrl(e) {
  1147. if (e.length) {
  1148. this.ruleForm.video_url = e[0].url;
  1149. this.ruleForm.video_cover_pic = e[0].thumb_url;
  1150. }
  1151. },
  1152. /*---商品分类----*/
  1153. selectCat(cats) {
  1154. this.cats = cats;
  1155. let arr = [];
  1156. cats.map(v => {
  1157. arr.push(v.id);
  1158. })
  1159. this.ruleForm.cats = arr;
  1160. this.$refs.ruleForm.validateField('cats');
  1161. },
  1162. selectMchCat(cats) {
  1163. this.mchCats = cats;
  1164. let arr = [];
  1165. cats.map(v => {
  1166. arr.push(v.id);
  1167. })
  1168. this.ruleForm.mchCats = arr;
  1169. this.$refs.ruleForm.validateField('mchCats');
  1170. },
  1171. /*---商品分类end----*/
  1172. /*----规格start----*/
  1173. // 规格组合
  1174. makeAttrGroup(e) {
  1175. let self = this;
  1176. let array = [];
  1177. self.attrGroups.forEach(function(attrGroupItem, attrGroupIndex) {
  1178. attrGroupItem.attr_list.forEach(function(attrListItem, attrListIndex) {
  1179. let object = {
  1180. attr_group_id: attrGroupItem.attr_group_id,
  1181. attr_group_name: attrGroupItem.attr_group_name,
  1182. attr_id: attrListItem.attr_id,
  1183. attr_name: attrListItem.attr_name,
  1184. };
  1185. if (!array[attrGroupIndex]) {
  1186. array[attrGroupIndex] = [];
  1187. }
  1188. array[attrGroupIndex].push(object)
  1189. });
  1190. });
  1191. // 2.属性排列组合
  1192. const res = array.reduce((osResult, options) => {
  1193. return options.reduce((oResult, option) => {
  1194. if (!osResult.length) {
  1195. return oResult.concat(option)
  1196. } else {
  1197. return oResult.concat(osResult.map(o => [].concat(o, option)))
  1198. }
  1199. }, [])
  1200. }, []);
  1201. console.log('makeAttrGroup', res)
  1202. // 3.组合结果赋值
  1203. for (let i in res) {
  1204. const options = Array.isArray(res[i]) ? res[i] : [res[i]];
  1205. const row = {
  1206. attr_list: options,
  1207. stock: typeof(self.ruleForm.attr[i]) == 'undefined' ? 0 : self.ruleForm.attr[i].stock,
  1208. price: typeof(self.ruleForm.attr[i]) == 'undefined' ? 0 : self.ruleForm.attr[i].price,
  1209. original_price: typeof(self.ruleForm.attr[i]) == 'undefined' ? 0 : self.ruleForm.attr[i].original_price,
  1210. cost_price: typeof(self.ruleForm.attr[i]) == 'undefined' ? 0 : self.ruleForm.attr[i].cost_price,
  1211. goods_no: typeof(self.ruleForm.attr[i]) == 'undefined' ? '' : self.ruleForm.attr[i].goods_no,
  1212. weight: typeof(self.ruleForm.attr[i]) == 'undefined' ? 0 : self.ruleForm.attr[i].weight,
  1213. pic_url: typeof(self.ruleForm.attr[i]) == 'undefined' ? '' : self.ruleForm.attr[i].pic_url,
  1214. distributionLevelList: [],
  1215. levelPrice: typeof(self.ruleForm.attr[i]) == 'undefined' ? {} : self.ruleForm.attr[i].levelPrice,
  1216. sign_id: typeof(self.ruleForm.attr[i]) == 'undefined' ? '' : self.ruleForm.attr[i].sign_id,
  1217. is_show: true,
  1218. reserve_max_buy: typeof(self.ruleForm.attr[i]) == 'undefined' ? 0 : self.ruleForm.attr[i].reserve_max_buy,
  1219. reserve_date_type: typeof(self.ruleForm.attr[i]) == 'undefined' ? 1 : self.ruleForm.attr[i].reserve_date_type,
  1220. reserve_date: typeof(self.ruleForm.attr[i]) == 'undefined' ? null : self.ruleForm.attr[i].reserve_date,
  1221. reserve_time_range_type: typeof(self.ruleForm.attr[i]) == 'undefined' ? 1 : self.ruleForm.attr[i].reserve_time_range_type,
  1222. time_slot_type: typeof(self.ruleForm.attr[i]) == 'undefined' ? 1 : self.ruleForm.attr[i].time_slot_type,
  1223. reserve_time_slot: typeof(self.ruleForm.attr[i]) == 'undefined' ? null : self.ruleForm.attr[i].reserve_time_slot,
  1224. reserve_price_type: typeof(self.ruleForm.attr[i]) == 'undefined' ? 0 : self.ruleForm.attr[i].reserve_price_type,
  1225. reserve_time_slot_price: typeof(self.ruleForm.attr[i]) == 'undefined' ? null : self.ruleForm.attr[i].reserve_time_slot_price,
  1226. reserve_week: typeof(self.ruleForm.attr[i]) == 'undefined' ? [0,1,2,3,4,5,6] : self.ruleForm.attr[i].reserve_week,
  1227. dayArr: typeof(self.ruleForm.attr[i]) == 'undefined' ? [] : self.ruleForm.attr[i].dayArr,
  1228. checkWeekList: typeof(self.ruleForm.attr[i]) == 'undefined' ? [] : self.ruleForm.attr[i].checkWeekList,
  1229. checkRangeList: typeof(self.ruleForm.attr[i]) == 'undefined' ? [] : self.ruleForm.attr[i].checkRangeList,
  1230. selectTimeList: typeof(self.ruleForm.attr[i]) == 'undefined' ? [] : self.ruleForm.attr[i].selectTimeList,
  1231. finalData: typeof(self.ruleForm.attr[i]) == 'undefined' ? [] : self.ruleForm.attr[i].finalData,
  1232. service_min: typeof(self.ruleForm.attr[i]) == 'undefined' ? [] : self.ruleForm.attr[i].service_min,
  1233. unit: typeof(self.ruleForm.attr[i]) == 'undefined' ? [] : self.ruleForm.attr[i].unit,
  1234. };
  1235. let arr = [];
  1236. row.attr_list.forEach(val => {
  1237. arr.push(val.attr_id);
  1238. })
  1239. // console.info(arr.join(":"),"::::");
  1240. row.sign_id = arr.join(":");
  1241. // 动态绑定多规格会员价
  1242. let obj = {};
  1243. self.member_level_list.forEach(function(item, index) {
  1244. let key = 'level' + item.level;
  1245. obj[key] = 0;
  1246. });
  1247. row['member_price'] = obj;
  1248. // 3-1.已设置数据的优先使用原数据
  1249. if (self.ruleForm.attr.length) {
  1250. for (let j in self.ruleForm.attr) {
  1251. const oldOptions = [];
  1252. for (let k in self.ruleForm.attr[j].attr_list) {
  1253. oldOptions.push(self.ruleForm.attr[j].attr_list[k].attr_name)
  1254. }
  1255. const newOptions = [];
  1256. for (let k in options) {
  1257. newOptions.push(options[k].attr_name)
  1258. }
  1259. if (oldOptions.toString() === newOptions.toString()) {
  1260. row['price'] = self.ruleForm.attr[j].price;
  1261. row['stock'] = self.ruleForm.attr[j].stock;
  1262. row['original_price'] = self.ruleForm.attr[j].original_price;
  1263. row['cost_price'] = self.ruleForm.attr[j].cost_price;
  1264. row['goods_no'] = self.ruleForm.attr[j].goods_no;
  1265. row['weight'] = self.ruleForm.attr[j].weight;
  1266. row['pic_url'] = self.ruleForm.attr[j].pic_url;
  1267. row['is_show'] = Boolean(self.ruleForm.attr[j].is_show);
  1268. break
  1269. }
  1270. }
  1271. }
  1272. res[i] = row;
  1273. }
  1274. self.ruleForm.attr = res;
  1275. self.ruleForm.attr_groups = JSON.parse(JSON.stringify(self.attrGroups));
  1276. console.log(self.ruleForm.attr, '-------------------------------attr');
  1277. },
  1278. // 批量设置
  1279. batchAttr(key) {
  1280. let self = this;
  1281. if (self.batch[key] && self.batch[key] >= 0 || key === 'goods_no') {
  1282. self.ruleForm.attr.forEach(function(item, index) {
  1283. // 批量设置会员价
  1284. // 判断字符串是否出现过,并返回位置
  1285. if (key.indexOf('level') !== -1) {
  1286. item['member_price'][key] = self.batch[key];
  1287. } else {
  1288. item[key] = self.batch[key];
  1289. }
  1290. });
  1291. }
  1292. },
  1293. destroyCat(value) {
  1294. this.cats = this.cats.filter(function(item) {
  1295. return value.id !== item.id
  1296. });
  1297. this.ruleForm.cats = this.cats.map(function(item) {
  1298. return item.id;
  1299. })
  1300. },
  1301. /*----规格end----*/
  1302. submit() {
  1303. if(this.ruleForm.cats.length && (typeof this.ruleForm.cats[0]) !== 'number'){
  1304. let idarr = [];
  1305. this.ruleForm.cats.forEach(item => {
  1306. idarr.push(item.id);
  1307. });
  1308. this.ruleForm.cats = JSON.parse(JSON.stringify(idarr));
  1309. }
  1310. let _ = this
  1311. if(this.ruleForm.goods_type == 3){
  1312. if(this.ruleForm.is_attr == 1){
  1313. let skus = [];
  1314. this.ruleForm.attr.forEach(item => {
  1315. skus.push({
  1316. attr_list: JSON.parse(JSON.stringify(item.attr_list)),
  1317. reserve_date_type: item.reserve_date_type,
  1318. reserve_date: item.reserve_date,
  1319. reserve_time_range_type: item.reserve_time_range_type,
  1320. time_slot_type: item.time_slot_type,
  1321. reserve_price_type: item.reserve_price_type,
  1322. reserve_max_buy: item.reserve_max_buy,
  1323. price: item.price,
  1324. original_price: item.original_price,
  1325. reserve_time_slot: item.reserve_time_slot,
  1326. reserve_time_slot_price: [],
  1327. reserve_week: item.reserve_week,
  1328. service_min: item.service_min,
  1329. unit: item.unit,
  1330. finalData: JSON.parse(JSON.stringify(item.finalData)),
  1331. selectTimeList: JSON.parse(JSON.stringify(item.selectTimeList))
  1332. });
  1333. });
  1334. skus.forEach(item => {
  1335. // 0统一设置价格 1 按时间段设置 2按天设置 - 只有按时间段才有finalData数据
  1336. // reserve_time_range_type 按天=1 时间段=2 2,2,0
  1337. // time_slot_type 自定义=1 自动划分=2
  1338. // reserve_price_type 统一售价=0 按时间段设置=1 按天设置=2
  1339. if(item.reserve_price_type == 1 && item.finalData && item.finalData.length){ // 按时间段设置价格
  1340. item.finalData.forEach(it => {
  1341. item.reserve_time_slot_price.push({
  1342. reserve_time: it.date,
  1343. price: it.selectTimes[0].price,
  1344. original_price: it.selectTimes[0].linePrice,
  1345. cost_price: 0,
  1346. reserve_max_buy: it.selectTimes[0].reservationNum,
  1347. time_spec: it.selectTimes
  1348. });
  1349. });
  1350. }
  1351. if(item.reserve_price_type == 0 && item.selectTimeList && item.selectTimeList.length){ // 统一设置价格
  1352. // time_slot_type = 1 自定义时间段 = 2 自动划分
  1353. if(item.time_slot_type == 1){ // 自定义时间段
  1354. item.selectTimeList.forEach(it => {
  1355. item.reserve_time_slot_price.push({
  1356. reserve_time: it.date,
  1357. price: item.price,
  1358. original_price: item.original_price,
  1359. cost_price: 0,
  1360. reserve_max_buy: item.reserve_max_buy,
  1361. time_spec: it.children
  1362. });
  1363. });
  1364. }
  1365. if(item.time_slot_type == 2){ // 自动划分
  1366. item.selectTimeList.forEach(it => {
  1367. item.reserve_time_slot_price.push({
  1368. reserve_time: it.date,
  1369. price: item.price,
  1370. original_price: item.original_price,
  1371. cost_price: 0,
  1372. reserve_max_buy: item.reserve_max_buy,
  1373. time_spec: it.checkedIntervalList
  1374. });
  1375. });
  1376. }
  1377. }
  1378. if (item.reserve_price_type == 2) { // 按天设置价格
  1379. console.log('item.reserve_price_type == 2item.reserve_price_type == 2item.reserve_price_type == 2', item)
  1380. }
  1381. });
  1382. skus.forEach(item => {
  1383. // 0 统一,1 时间段,2 按天
  1384. if(item.reserve_price_type == 1){ // 时间段
  1385. item.reserve_time_slot_price.forEach(it => {
  1386. it.time_spec = it.time_spec.map(itc => {
  1387. _.setFormPrice(itc.price, 'price', 3)
  1388. _.setFormPrice(itc.linePrice, 'original_price', 3)
  1389. return {
  1390. spec_time: itc.time,
  1391. start: itc.time ? itc.time.split('-')[0] : '',
  1392. end: itc.time ? itc.time.split('-')[1] : '',
  1393. price: itc.price,
  1394. original_price: itc.linePrice,
  1395. cost_price: 0,
  1396. reserve_max_buy: itc.reservationNum,
  1397. checked: 1,
  1398. is_next: 0,
  1399. }
  1400. });
  1401. });
  1402. } else if(item.reserve_price_type == 2) { // 按天
  1403. item.reserve_time_slot_price = {}
  1404. item.finalData.forEach(it => {
  1405. _.setFormPrice(it.price, 'price', 2)
  1406. _.setFormPrice(it.linePrice, 'original_price', 2)
  1407. item.reserve_time_slot_price[it.date] = {
  1408. reserve_time: it.date,
  1409. price: it.price,
  1410. original_price: it.linePrice,
  1411. cost_price: 0,
  1412. reserve_max_buy: it.reservationNum,
  1413. }
  1414. });
  1415. }else{ // 统一
  1416. _.setFormPrice(item.price, 'price', 2)
  1417. _.setFormPrice(item.original_price, 'original_price', 2)
  1418. item.reserve_time_slot_price.forEach(it => {
  1419. // _.setFormPrice(it.price, 'price', 2)
  1420. // _.setFormPrice(it.linePrice, 'original_price', 2)
  1421. it.time_spec = it.time_spec.map(itc => {
  1422. return {
  1423. spec_time: itc,
  1424. start: itc.split('-')[0] || '',
  1425. end: itc.split('-')[1] || '',
  1426. price: it.price,
  1427. original_price: it.linePrice || item.original_price,
  1428. cost_price: 0,
  1429. reserve_max_buy: it.reservationNum || item.reserve_max_buy,
  1430. checked: 1,
  1431. is_next: 0,
  1432. }
  1433. });
  1434. });
  1435. }
  1436. });
  1437. this.ruleForm.reserve.skus = JSON.parse(JSON.stringify(skus));
  1438. }else{
  1439. this.ruleForm.reserve.reserve_time_slot_price = [];
  1440. let preList = [];
  1441. if(this.ruleForm.reserve.reserve_price_type == 1){
  1442. preList = this.$refs.priceSet && this.$refs.priceSet.selectedDates ? this.$refs.priceSet.selectedDates : [];
  1443. } else if (this.ruleForm.reserve.reserve_price_type == 2) { // 按天 - 有可能需要修改
  1444. preList = this.$refs.priceSet && this.$refs.priceSet.selectedDates ? this.$refs.priceSet.selectedDates : [];
  1445. }else{
  1446. preList = this.$refs.timeSelect && this.$refs.timeSelect.selectedDates ? this.$refs.timeSelect.selectedDates : [];
  1447. if(this.ruleForm.reserve.time_slot_type == 1){
  1448. preList.forEach(item => {
  1449. item.selectTimes = item.children
  1450. });
  1451. }
  1452. if(this.ruleForm.reserve.time_slot_type == 2){
  1453. preList.forEach(item => {
  1454. item.selectTimes = item.checkedIntervalList
  1455. });
  1456. }
  1457. }
  1458. if (this.ruleForm.reserve.reserve_price_type == 2) { // 按天
  1459. this.ruleForm.reserve.reserve_time_slot_price = {}
  1460. preList.forEach(item => {
  1461. _.setFormPrice(item.price, 'price', 1)
  1462. _.setFormPrice(item.linePrice, 'original_price', 1)
  1463. this.ruleForm.reserve.reserve_time_slot_price[item.date] = {
  1464. reserve_time: item.date,
  1465. price: item.price,
  1466. original_price: item.linePrice,
  1467. cost_price: 0,
  1468. reserve_max_buy: item.reservationNum,
  1469. }
  1470. });
  1471. } else { // 统一/时间段
  1472. preList.forEach(item => {
  1473. this.ruleForm.reserve.reserve_time_slot_price.push({
  1474. reserve_time: item.date,
  1475. price: this.ruleForm.price,
  1476. original_price: this.ruleForm.original_price,
  1477. cost_price: 0,
  1478. reserve_max_buy: this.ruleForm.reserve.reserve_max_buy,
  1479. time_spec: item.selectTimes
  1480. });
  1481. });
  1482. }
  1483. if(this.ruleForm.reserve.reserve_price_type == 1){ // 按时间段
  1484. this.ruleForm.reserve.reserve_time_slot_price.forEach(item => {
  1485. item.time_spec = item.time_spec.map(it => {
  1486. _.setFormPrice(it.price, 'price', 1)
  1487. _.setFormPrice(it.linePrice, 'original_price', 1)
  1488. return {
  1489. spec_time: it.time,
  1490. start: it.time ? it.time.split('-')[0] : '',
  1491. end: it.time ? it.time.split('-')[1] : '',
  1492. price: it.price,
  1493. original_price: it.linePrice,
  1494. cost_price: 0,
  1495. reserve_max_buy: it.reservationNum,
  1496. checked: 1,
  1497. is_next: 0,
  1498. }
  1499. });
  1500. });
  1501. } else if(this.ruleForm.reserve.reserve_price_type == 2){ // 按天
  1502. }else{ // 统一
  1503. this.ruleForm.reserve.reserve_time_slot_price.forEach(item => {
  1504. item.time_spec = item.time_spec.map(it => {
  1505. return {
  1506. spec_time: it,
  1507. start: it.split('-')[0] || '',
  1508. end: it.split('-')[1] || '',
  1509. price: this.ruleForm.price,
  1510. original_price: this.ruleForm.original_price,
  1511. cost_price: 0,
  1512. reserve_max_buy: this.ruleForm.reserve.reserve_max_buy,
  1513. checked: 1,
  1514. is_next: 0,
  1515. }
  1516. });
  1517. });
  1518. }
  1519. }
  1520. }
  1521. this.$refs['ruleForm'].validate((valid) => {
  1522. if (valid) {
  1523. // console.log(this.ruleForm)
  1524. // return ;
  1525. let self = this;
  1526. if (Number(self.ruleForm.extra.member_buy_limit_setting.every_num) > 0 && Number(self.ruleForm.extra.member_buy_limit_setting.every_num) < Number(self.ruleForm.extra.member_buy_limit_setting.nums)) {
  1527. this.$message.error('每次限购数量不能小于起购数量');
  1528. return
  1529. }
  1530. if (Number(self.ruleForm.extra.member_buy_limit_setting.every_day_num) > 0 && Number(self.ruleForm.extra.member_buy_limit_setting.every_day_num) < Number(self.ruleForm.extra.member_buy_limit_setting.nums)) {
  1531. this.$message.error('每天限购数量不能小于起购数量');
  1532. return
  1533. }
  1534. if (self.ruleForm.is_attr == 1) {
  1535. if (this.attrGroups.length == 0) {
  1536. this.$message.error('请完善规格组');
  1537. return
  1538. }
  1539. self.ruleForm.extra.member_price_setting = this.getMemberPrice(this.ruleForm.attr);
  1540. }
  1541. if (!self.ruleForm.extra.full_reduce_price_limit) {
  1542. self.ruleForm.extra.full_reduce_price_limit = 0;
  1543. }
  1544. if (!self.ruleForm.extra.full_reduce_money) {
  1545. self.ruleForm.extra.full_reduce_money = 0;
  1546. }
  1547. if (!self.ruleForm.extra.score_give_setting.give_num) {
  1548. self.ruleForm.extra.score_give_setting.give_num = 0;
  1549. }
  1550. if(self.ruleForm.extra.is_repurchase == 1){
  1551. let repurchase_setting = self.ruleForm.extra.repurchase_setting
  1552. if(repurchase_setting.length <= 0){
  1553. this.$message.error('请完善复购设置')
  1554. return
  1555. }
  1556. let err = 0
  1557. let flag_start = -1
  1558. let flag_end = -1
  1559. for(let i = 0; i < repurchase_setting.length; i++){
  1560. if(repurchase_setting[i].start < 0 || repurchase_setting[i].end <= 0 || repurchase_setting[i].price < 0 || repurchase_setting[i].start > repurchase_setting[i].end){
  1561. err = 1
  1562. break
  1563. }
  1564. if(i > 0){
  1565. if(repurchase_setting[i].start >= flag_start && repurchase_setting[i].start <= flag_end){
  1566. err = 2
  1567. break
  1568. }
  1569. }
  1570. flag_start = repurchase_setting[i].start
  1571. flag_end = repurchase_setting[i].end
  1572. }
  1573. if(err > 0){
  1574. if(err == 1){
  1575. this.$message.error('请输入正确的复购设置')
  1576. }else{
  1577. this.$message.error('复购件数区间必须递增')
  1578. }
  1579. return
  1580. }
  1581. }
  1582. //把纯数字转字符
  1583. this.ruleForm.goods_name = this.ruleForm.goods_name + '';
  1584. this.ruleForm.subtitle = this.ruleForm.subtitle + '';
  1585. self.btnLoading = true;
  1586. let requesturl = 'mall/goods/edit'
  1587. if (this.smartform_addons_arr && this.smartform_addons_arr.component && this.goodsId > 0) {
  1588. this.smartGoodForm.goods_id = this.goodsId
  1589. let taohua = JSON.parse(JSON.stringify(self.ruleForm))
  1590. if (this.$refs.smartForm.smartForm[0]) {
  1591. this.smartGoodForm.template_id = this.$refs.smartForm.smartForm[0].id
  1592. this.smartGoodForm.status = this.$refs.smartForm.smartGoodForm.is_relation
  1593. this.ruleForm.addons.SmartForm = this.smartGoodForm;
  1594. //params = Object.assign(taohua);
  1595. params = Object.assign(this.ruleForm);
  1596. } else {
  1597. params = Object.assign(taohua, this.cForm);
  1598. }
  1599. } else {
  1600. // params = Object.assign(self.ruleForm, this.cForm);
  1601. params = Object.assign(self.ruleForm);
  1602. }
  1603. // 过滤虚拟商品
  1604. if (this.ruleForm.goods_type == 1 && this.community_addons_arr && this.community_addons_arr.component) {
  1605. if (this.$refs.community.communityGoodsForm) {
  1606. if (this.$refs.community.communityGoodsForm.enable == 1 && (this.ruleForm.freight_type.includes(2) || this.ruleForm.freight_type.includes(3))) {
  1607. self.$message.error('快递方式已勾选到店自提或同城配送,无法开启社区团购');
  1608. self.btnLoading = false;
  1609. return;
  1610. }
  1611. this.communityGoodForm.enable = this.$refs.community.communityGoodsForm.enable
  1612. this.communityGoodForm.enable_refund = this.$refs.community.communityGoodsForm.enable_refund
  1613. this.communityGoodForm.supported_logistics = this.$refs.community.communityGoodsForm.supported_logistics
  1614. this.communityGoodForm.community_arr_ids = this.$refs.community.community_arr_ids
  1615. if (this.communityGoodForm.enable == 1 && this.communityGoodForm.supported_logistics.length == 0) {
  1616. self.$message.error('社区团购配送方式至少选择一种');
  1617. return;
  1618. }
  1619. this.ruleForm.addons.Community = this.communityGoodForm;
  1620. params = Object.assign(this.ruleForm);
  1621. }
  1622. }
  1623. if (this.valet_order_addons_arr && this.valet_order_addons_arr.component && this.goodsId > 0) {
  1624. if (this.$refs.valet_order.valetOrderGoodsForm) {
  1625. if (this.$refs.valet_order.valetOrderGoodsForm.status == 1 && (this.ruleForm.freight_type.includes(2) || this.ruleForm.freight_type.includes(3))) {
  1626. self.$message.error('快递方式已勾选到店自提或同城配送,无法设为代购买商品');
  1627. self.btnLoading = false;
  1628. return;
  1629. }
  1630. this.valetOrderGoodForm.status = this.$refs.valet_order.valetOrderGoodsForm.status
  1631. this.ruleForm.addons.ValetOrder = this.valetOrderGoodForm;
  1632. params = Object.assign(this.ruleForm);
  1633. }
  1634. }
  1635. // 深拷贝一份数据,让checkbox正常显示
  1636. let submitForm = JSON.parse(JSON.stringify(params))
  1637. if (submitForm.is_attr == 1) {
  1638. for(let i = 0; i < submitForm.attr.length; i++){
  1639. submitForm.attr[i]['is_show'] = submitForm.attr[i]['is_show'] ? 1 : 0
  1640. }
  1641. }
  1642. if (this.ruleForm.goods_subtype == 1) {
  1643. for (let item of submitForm.extra.symptom_list) {
  1644. item = item + ''
  1645. if (item.trim() === '') {
  1646. self.$message.error('请填写疾病名称');
  1647. self.btnLoading = false;
  1648. return
  1649. }
  1650. }
  1651. }
  1652. // console.log(params, self.ruleForm, this.cForm, 'sumbit ============ ');return null;
  1653. console.log(params, self.ruleForm, this.cForm, 'sumbit ============ ');
  1654. console.log(submitForm, 'submitForm ============ ');
  1655. // return null;
  1656. // if (this.ruleForm.price <= 0) {
  1657. // self.btnLoading = false;
  1658. // this.$message.error('价格不能为0')
  1659. // return null
  1660. // }
  1661. request({
  1662. params: {
  1663. r: requesturl
  1664. },
  1665. method: 'post',
  1666. data: {
  1667. form: JSON.stringify(submitForm),
  1668. }
  1669. }).then(e => {
  1670. self.btnLoading = false;
  1671. if (e.data.code == 0) {
  1672. self.$message.success(e.data.msg);
  1673. this.$navigate({
  1674. r: 'mall/goods/index'
  1675. })
  1676. } else {
  1677. self.$message.error(e.data.msg);
  1678. }
  1679. }).catch(e => {
  1680. self.$message.error(e.data.msg);
  1681. self.btnLoading = false;
  1682. });
  1683. }
  1684. });
  1685. },
  1686. setFormPrice(price, key) {
  1687. if (this.ruleForm.is_attr == 1 && this.ruleForm.goods_type == 3) {
  1688. // 重新设置价格
  1689. if (price > 0) {
  1690. // this.$set(this.ruleForm, key, this.ruleForm[key] > 0 ? Math.min(this.ruleForm[key], price) : price)
  1691. // if (this.ruleForm[key] <= 0) this.$message.error("价格不能为0")
  1692. }
  1693. }
  1694. },
  1695. addons_data_change(e) {
  1696. Object.assign(this.ruleForm.addons, e);
  1697. console.log(this.ruleForm.addons, '=======addons====');
  1698. // this.ruleForm.addons.coupon_selection = e;
  1699. },
  1700. //跳转新增优惠券界面
  1701. // handle_coupon() {
  1702. // this.$navigate({
  1703. // r: 'coupon/default/edit'
  1704. // })
  1705. // },
  1706. checkoutChange(it) {
  1707. console.log(it)
  1708. },
  1709. getFreight() { // 获取运费规则选项
  1710. let self = this;
  1711. request({
  1712. params: {
  1713. r: 'mall/postage-rules/all-list'
  1714. },
  1715. method: 'get',
  1716. data: {}
  1717. }).then(e => {
  1718. if (e.data.code == 0) {
  1719. self.freight.list = e.data.data.list;
  1720. // 添加商品时使用默认运费
  1721. self.freight.list.unshift({
  1722. id: 0,
  1723. name: '默认运费',
  1724. status: 1
  1725. })
  1726. console.log(self.freight.list)
  1727. } else {
  1728. self.$message.error(e.data.msg);
  1729. }
  1730. }).catch(e => {
  1731. console.log(e);
  1732. });
  1733. },
  1734. freightChange(e) {
  1735. console.log(e)
  1736. },
  1737. // 获取规格会员价
  1738. getMemberPrice(attr) {
  1739. let that = this;
  1740. let member_price_setting = {};
  1741. let levels = objectKeys(attr[0].member_price_setting);
  1742. levels.forEach(level => {
  1743. that.$set(member_price_setting, level, {});
  1744. });
  1745. attr.forEach((v) => {
  1746. let sign_id = v.sign_id;
  1747. for (const key in v.member_price_setting) {
  1748. member_price_setting[key][sign_id] = v.member_price_setting[key];
  1749. }
  1750. })
  1751. member_price_setting = member_price_setting;
  1752. return member_price_setting;
  1753. },
  1754. // // 轮播图拖拽
  1755. // dragBannarPic(e){
  1756. // // 拖拽后下标之前的值
  1757. // let oldValue = this.ruleForm.bannar_pic[e.newIndex];
  1758. // // 拖拽下标对应的值
  1759. // let newValue = this.ruleForm.bannar_pic[e.oldIndex];
  1760. // let bannarPic = [...this.ruleForm.bannar_pic];
  1761. // bannarPic.splice(e.oldIndex, 1);
  1762. // bannarPic.splice(e.newIndex, 0, newValue);
  1763. // Vue.set(this.ruleForm, 'bannar_pic', [...bannarPic]);
  1764. // },
  1765. dragBannarPic(e) {
  1766. // 拖拽后下标之前的值
  1767. let oldValue = this.ruleForm.bannar_pic[e.newIndex];
  1768. // 拖拽下标对应的值
  1769. let newValue = this.ruleForm.bannar_pic[e.oldIndex];
  1770. this.ruleForm.bannar_pic[e.newIndex] = newValue;
  1771. this.ruleForm.bannar_pic[e.oldIndex] = oldValue;
  1772. },
  1773. appendRepurchaseItem(){
  1774. item = {start: 0, end: 0, price: 0}
  1775. this.ruleForm.extra.repurchase_setting.push(item)
  1776. },
  1777. delRepurchaseItem(index){
  1778. this.ruleForm.extra.repurchase_setting.splice(index, 1);
  1779. },
  1780. setRepurchase(index, field, val){
  1781. item = this.ruleForm.extra.repurchase_setting[index]
  1782. item[field] = Number(val)
  1783. this.$set(this.ruleForm.extra.repurchase_setting, index, item)
  1784. },
  1785. formatGiveNumber(value, pindex) {
  1786. if (this.ruleForm.extra[pindex].give_type == 2) {
  1787. this.ruleForm.extra[pindex].give_num = value.replace(/[^\d]/g, "")
  1788. } else {
  1789. let temp = value.toString();
  1790. temp = temp.replace(/。/g, ".");
  1791. temp = temp.replace(/[^\d.]/g, ""); //清除"数字"和"."以外的字符
  1792. temp = temp.replace(/^\./g, ""); //验证第一个字符是数字
  1793. temp = temp.replace(/\.{2,}/g, ""); //只保留第一个, 清除多余的
  1794. temp = temp.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  1795. temp = temp.replace(/^(\-)*(\d+)\.(\d\d).*$/, "$1$2.$3");
  1796. this.ruleForm.extra[pindex].give_num = temp
  1797. }
  1798. },
  1799. handleGiveTypeChange(pindex) {
  1800. if (this.ruleForm.extra[pindex].give_type == 2) {
  1801. let giveNum = this.ruleForm.extra[pindex].give_num
  1802. giveNum = giveNum ? giveNum : 0
  1803. this.ruleForm.extra[pindex].give_num = parseInt(giveNum)
  1804. }
  1805. },
  1806. // 预约商品-时间范围选择处理
  1807. dateSelectChange(val) {
  1808. let arr = [];
  1809. let txtArr = [{val: 0,txt: '周日',children: []},{val: 1,txt: '周一',children: []},{val: 2,txt: '周二',children: []},{val: 3,txt: '周三',children: []},{val: 4,txt: '周四',children: []},{val: 5,txt: '周五',children: []},{val: 6,txt: '周六',children: []}];
  1810. if (val) {
  1811. let arr1 = [];
  1812. let str1 = val[0];
  1813. let str2 = val[1];
  1814. let unixDb = str1.getTime() - 24 * 60 * 60 * 1000;
  1815. let unixDe = str2.getTime() - 24 * 60 * 60 * 1000;
  1816. for(let j = unixDb; j <= unixDe;){
  1817. j = j + 24 * 60 * 60 * 1000
  1818. arr1.push(new Date(parseInt(j)))
  1819. }
  1820. for(let i = 0; i < arr1.length; i++){
  1821. txtArr.forEach(item => {
  1822. if(item.val == arr1[i].getDay()){
  1823. let fm = this.formatDate(arr1[i])
  1824. item.children.push(fm);
  1825. }
  1826. })
  1827. }
  1828. txtArr.forEach(item => {
  1829. if(item.children.length){
  1830. arr.push(item);
  1831. }
  1832. });
  1833. this.dayArr = arr;
  1834. }
  1835. this.checkWeekList = [];
  1836. let warr = [];
  1837. this.dayArr.forEach(item => {
  1838. warr.push(item.txt);
  1839. });
  1840. this.checkWeekList = [...new Set(warr)];
  1841. this.weekSelectChange();
  1842. },
  1843. weekSelectChange() {
  1844. let selectArr = [];
  1845. let selectDateArr = [];
  1846. for(let i = 0; i < this.dayArr.length; i++){
  1847. this.checkWeekList.forEach(item => {
  1848. if(item == this.dayArr[i].txt){
  1849. selectArr.push(this.dayArr[i]);
  1850. }
  1851. });
  1852. }
  1853. for(let j = 0; j < selectArr.length; j++){
  1854. selectDateArr = selectDateArr.concat(selectArr[j].children);
  1855. }
  1856. this.ruleForm.reserve.reserve_date = selectDateArr;
  1857. },
  1858. formatDate(date) {
  1859. let result = '';
  1860. let year = date.getFullYear().toString().padStart(4, '0');
  1861. let month = (date.getMonth() + 1).toString().padStart(2, '0');
  1862. let day = date.getDate().toString().padStart(2, '0');
  1863. let hour = date.getHours().toString().padStart(2, '0');
  1864. let minute = date.getMinutes().toString().padStart(2, '0');
  1865. let second = date.getSeconds().toString().padStart(2, '0');
  1866. result = `${year}-${month}-${day}`;
  1867. return result;
  1868. },
  1869. resetDateInfo(e) {
  1870. if(this.ruleForm.reserve.reserve_price_type == 1){
  1871. let dates = e;
  1872. if(this.ruleForm.reserve.time_slot_type == 1){
  1873. let arr = [];
  1874. dates.forEach(item => {
  1875. arr.push({
  1876. date: item.date,
  1877. times: item.children,
  1878. isSelect: false
  1879. });
  1880. });
  1881. if(arr.length){
  1882. arr[0].isSelect = true;
  1883. }
  1884. if(!this.isEdit){
  1885. this.$nextTick(() => {
  1886. this.$refs.priceSet.initData(arr, 'from7');
  1887. });
  1888. }else{
  1889. this.$nextTick(() => {
  1890. this.$refs.priceSet.initData(this.initializationDates);
  1891. this.isEdit = false;
  1892. });
  1893. }
  1894. }
  1895. if(this.ruleForm.reserve.time_slot_type == 2){
  1896. let arr1 = [];
  1897. dates.forEach(item => {
  1898. arr1.push({
  1899. date: item.date,
  1900. times: item.checkedIntervalList,
  1901. isSelect: false
  1902. });
  1903. });
  1904. if(arr1.length){
  1905. arr1[0].isSelect = true;
  1906. }
  1907. if(!this.isEdit){
  1908. this.$nextTick(() => {
  1909. this.$refs.priceSet.initData(arr1, 'from9');
  1910. });
  1911. }else{
  1912. this.$nextTick(() => {
  1913. this.$refs.priceSet.initData(this.initializationDates);
  1914. this.isEdit = false;
  1915. });
  1916. }
  1917. }
  1918. }
  1919. },
  1920. async loadData(id = 1) {
  1921. await request({
  1922. params: {
  1923. r: 'mall/goods/regions',
  1924. id: id,
  1925. },
  1926. method: 'get',
  1927. }).then(e => {
  1928. if (e.data.code == 0) {
  1929. this.provinces = e.data.data;
  1930. }
  1931. }).catch(e => {
  1932. console.log(e);
  1933. this.listLoading = false;
  1934. this.$message.error('网络错误');
  1935. });
  1936. },
  1937. // 省市区三级联动
  1938. regionChange(e, level) {
  1939. let self = this;
  1940. self.ruleForm.reserve.lng = e.lng;
  1941. self.ruleForm.reserve.lat = e.lat;
  1942. self.long_lat = e.lng + '-' + e.lat;
  1943. request({
  1944. params: {
  1945. r: 'mall/goods/regions',
  1946. id: e.id,
  1947. },
  1948. method: 'get',
  1949. }).then(e => {
  1950. if (e.data.code == 0) {
  1951. switch (level) {
  1952. case 1:
  1953. self.citys = e.data.data;
  1954. this.ruleForm.reserve.province_id = this.provinceInfo.id
  1955. break;
  1956. case 2:
  1957. self.districts = e.data.data;
  1958. this.ruleForm.reserve.city_id = this.cityInfo.id
  1959. break;
  1960. case 3:
  1961. self.streets = e.data.data;
  1962. this.ruleForm.reserve.district_id = this.districtInfo.id
  1963. break;
  1964. }
  1965. } else {
  1966. self.$message.error(e.data.msg);
  1967. }
  1968. }).catch(e => {
  1969. console.log(e);
  1970. self.$message.error('网络错误');
  1971. return false;
  1972. });
  1973. },
  1974. //地图确定事件
  1975. mapEvent(e) {
  1976. for (let i in this.provinces) {
  1977. if (e.address.indexOf(this.provinces[i].name) !== -1) {
  1978. this.ruleForm.reserve.province_id = this.provinces[i].id;
  1979. this.provinceInfo = this.provinces[i];
  1980. request({
  1981. params: {
  1982. r: 'mall/goods/get-regions',
  1983. region_id: this.provinces[i].id,
  1984. },
  1985. method: 'get',
  1986. }).then(res => {
  1987. if (res.data.code == 0) {
  1988. this.citys = res.data.data;
  1989. for (let i in this.citys) {
  1990. if (e.address.indexOf(this.citys[i].name) !== -1) {
  1991. this.ruleForm.reserve.city_id = this.citys[i].id;
  1992. this.cityInfo = this.citys[i];
  1993. request({
  1994. params: {
  1995. r: 'mall/goods/get-regions',
  1996. region_id: this.citys[i].id,
  1997. },
  1998. method: 'get',
  1999. }).then(resp => {
  2000. if (resp.data.code == 0) {
  2001. this.districts = resp.data.data;
  2002. for (let i in this.districts) {
  2003. if (e.address.indexOf(this.districts[i].name) !== -1) {
  2004. this.ruleForm.reserve.district_id = this.districts[i].id;
  2005. this.districtInfo = this.districts[i];
  2006. }
  2007. }
  2008. } else {
  2009. this.$message.error(resp.data.msg);
  2010. }
  2011. }).catch(error => {
  2012. console.log(error);
  2013. this.$message.error('网络错误');
  2014. });
  2015. }
  2016. }
  2017. } else {
  2018. this.$message.error(res.data.msg);
  2019. }
  2020. }).catch(err => {
  2021. console.log(err);
  2022. this.$message.error('网络错误');
  2023. });
  2024. }
  2025. }
  2026. this.ruleForm.reserve.lng = e.long;
  2027. this.ruleForm.reserve.lat = e.lat;
  2028. this.ruleForm.reserve.detail = e.address;
  2029. this.long_lat = e.lat + '-' + e.long;
  2030. this.$forceUpdate();
  2031. },
  2032. changeSwitch()
  2033. {
  2034. this.$forceUpdate()
  2035. },
  2036. getReservePlace() {
  2037. let self = this;
  2038. for (let i in self.provinces) {
  2039. if (self.ruleForm.reserve.province_id == self.provinces[i].id) {
  2040. self.provinceInfo = self.provinces[i];
  2041. request({
  2042. params: {
  2043. r: 'mall/goods/get-regions',
  2044. region_id: self.provinces[i].id,
  2045. },
  2046. method: 'get',
  2047. }).then(res => {
  2048. if (res.data.code == 0) {
  2049. self.citys = res.data.data;
  2050. for (let i in self.citys) {
  2051. if (self.ruleForm.reserve.city_id == self.citys[i].id) {
  2052. self.cityInfo = self.citys[i];
  2053. request({
  2054. params: {
  2055. r: 'mall/goods/get-regions',
  2056. region_id: self.citys[i].id,
  2057. },
  2058. method: 'get',
  2059. }).then(resp => {
  2060. if (resp.data.code == 0) {
  2061. self.districts = resp.data.data;
  2062. for (let i in self.districts) {
  2063. if (self.ruleForm.reserve.district_id == self.districts[i].id) {
  2064. self.districtInfo = self.districts[i];
  2065. }
  2066. }
  2067. } else {
  2068. self.$message.error(resp.data.msg);
  2069. }
  2070. }).catch(error => {
  2071. console.log(error);
  2072. self.$message.error('网络错误');
  2073. });
  2074. }
  2075. }
  2076. } else {
  2077. self.$message.error(res.data.msg);
  2078. }
  2079. }).catch(err => {
  2080. console.log(err);
  2081. self.$message.error('网络错误');
  2082. });
  2083. }
  2084. }
  2085. },
  2086. onChangeReserveTimeRangeType(val) {
  2087. this.ruleForm.reserve.reserve_price_type = 0
  2088. },
  2089. addressChange(e) {
  2090. this.ruleForm.searchAddress.province_id = e[0]
  2091. this.ruleForm.searchAddress.city_id = e[1]
  2092. this.ruleForm.searchAddress.district_id = e[2]
  2093. this.townList = []
  2094. this.ruleForm.searchAddress.town_id = ''
  2095. if (e.length == 3) {
  2096. this.getTownList(e[2]);
  2097. }
  2098. console.log(this.ruleForm.searchAddress.addressIdsMap, 'ruleForm.searchAddress.addressIdsMap')
  2099. },
  2100. getDistrict(level) {
  2101. if (level) {
  2102. level1 = level;
  2103. } else{
  2104. level1 = 1;
  2105. }
  2106. request({
  2107. params: {
  2108. r: 'common/region/get-district-list',
  2109. level: level1
  2110. },
  2111. }).then(e => {
  2112. if (e.data.code == 0) {
  2113. this.districtList = e.data.data
  2114. }
  2115. }).catch(e => {
  2116. });
  2117. },
  2118. getTownList(district_id) {
  2119. request({
  2120. params: {
  2121. r: 'common/region/get-town-list',
  2122. district_id: district_id
  2123. },
  2124. }).then(e => {
  2125. if (e.data.code == 0) {
  2126. this.townList = e.data.data.list;
  2127. }
  2128. }).catch(e => {
  2129. });
  2130. },
  2131. onChangeTown(val) {
  2132. this.ruleForm.searchAddress.town_id = val
  2133. },
  2134. goodsSelect1(param) {
  2135. console.log(1111222);
  2136. console.log(this.ruleForm.extra1_goods_id);
  2137. for (let j in param) {
  2138. let item = param[j];
  2139. if(this.ruleForm.id&&item.id==this.ruleForm.id){
  2140. continue;
  2141. }
  2142. let flag = true;
  2143. for (let i in this.extra1_goods_list) {
  2144. if (this.extra1_goods_list[i].goods_id == item.id) {
  2145. flag = false;
  2146. break;
  2147. }
  2148. }
  2149. if (flag) {
  2150. if(this.extra1_goods_list.length>=20){
  2151. this.$message.error('最多只能添加20件商品');
  2152. break;
  2153. }
  2154. this.extra1_goods_list.push({
  2155. goods_id: item.id,
  2156. price: item.price,
  2157. status: item.status,
  2158. goods_stock: item.stock,
  2159. goods_name: item.goods_name,
  2160. cover_pic: item.cover_pic,
  2161. });
  2162. this.ruleForm.extra1_goods_id.push(item.id);
  2163. }
  2164. }
  2165. },
  2166. goodsSelect2(param) {
  2167. for (let j in param) {
  2168. let item = param[j];
  2169. if(this.ruleForm.id&&item.id==this.ruleForm.id){
  2170. continue;
  2171. }
  2172. let flag = true;
  2173. for (let i in this.extra2_goods_list) {
  2174. if (this.extra2_goods_list[i].goods_id == item.id) {
  2175. flag = false;
  2176. break;
  2177. }
  2178. }
  2179. if (flag) {
  2180. if(this.extra2_goods_list.length>=20){
  2181. this.$message.error('最多只能添加20件商品');
  2182. break;
  2183. }
  2184. this.extra2_goods_list.push({
  2185. goods_id: item.id,
  2186. price: item.price,
  2187. status: item.status,
  2188. goods_stock: item.stock,
  2189. goods_name: item.goods_name,
  2190. cover_pic: item.cover_pic,
  2191. });
  2192. this.ruleForm.extra2_goods_id.push(item.id);
  2193. }
  2194. }
  2195. },
  2196. // 删除商品
  2197. // 删除商品
  2198. delFun(index,type) {
  2199. switch (type){
  2200. case 1:
  2201. this.extra1_goods_list.splice(index, 1);
  2202. var extra1_goods_id =[];
  2203. for(var item of this.extra1_goods_list){
  2204. extra1_goods_id.push(item.goods_id)
  2205. }
  2206. this.ruleForm.extra1_goods_id =extra1_goods_id;
  2207. break;
  2208. case 2:
  2209. this.extra2_goods_list.splice(index, 1);
  2210. var extra2_goods_id =[];
  2211. for(var item of this.extra2_goods_list){
  2212. extra2_goods_id.push(item.goods_id)
  2213. }
  2214. this.ruleForm.extra2_goods_id =extra2_goods_id;
  2215. break;
  2216. }
  2217. },
  2218. descriptionTemplateChange(val) {
  2219. this.ruleForm.extra.description_list = []
  2220. for (const field of this.descriptionTemplateList[val]?.fields ?? []) {
  2221. this.ruleForm.extra.description_list.push({
  2222. 'field': field,
  2223. 'value': ''
  2224. })
  2225. }
  2226. },
  2227. removeSymptom(index) {
  2228. if (this.ruleForm.extra.symptom_list.length > 1) {
  2229. this.ruleForm.extra.symptom_list.splice(index, 1);
  2230. } else {
  2231. this.$message.warning('至少保留一种疾病');
  2232. }
  2233. },
  2234. addMemberAloneBuyLimitSetting()
  2235. {
  2236. this.ruleForm.extra.member_alone_buy_limit_setting.push({
  2237. "level": '',
  2238. "every_month_num": 0,
  2239. });
  2240. this.$forceUpdate();
  2241. }
  2242. }
  2243. });
  2244. </script>